<?php
// +----------------------------------------------------------------------+
// | The CompanyName 星座女神                                             |
// +----------------------------------------------------------------------+
// | Copyright (c) 2016, CompanyName 星座女神. All rights reserved.       |
// +----------------------------------------------------------------------+
// | Authors: CompanyName 星座女神.                                       |
// |                                                                      |
// +----------------------------------------------------------------------+
/**
 * @version  2.2
 * @author   guokunsheng
 * @date     2017-07-012
 */

namespace app\astro\controller;

// 星盘记分类
class Totalpower
{
    private $debug = false;
    private $base_data = [];
    private $planet_power = [];
    private $house_power = [];
    private $house_score = [];
    public $influence = [];
    private $career = 0;

    public function __construct($data = [], $debug = false)
    {
        $this->debug = $debug;
        $this->base_data = $data;
        if (isset($data['planet_power'])) $this->planet_power = $data['planet_power'];
        if (isset($data['house_power'])) $this->house_power = $data['house_power'];
        $house_score = new Housescore($this->base_data);
        $this->house_score = $house_score->_initload();

    }

    public function _initload()
    {
        // 婚恋指数
        $love = $this->getLoveScore();
        $health = $this->getTheHealth();
        $this->career = $this->getTheCareer();
        $money = $this->getTheMoney();
        $home = $this->getTheHome();
        $study = $this->getTheStudy();

        $love += 150;
        $health += 150;

        $love = $love > 500 ? 500 : ($love < 0 ? 0 : round($love));
        $health = $health > 500 ? 500 : ($health < 0 ? 0 : round($health));
        $this->career = $this->career > 500 ? 500 : ($this->career < 0 ? 0 : round($this->career));
        $money = $money > 500 ? 500 : ($money < 0 ? 0 : round($money));
        $home = $home > 500 ? 500 : ($home < 0 ? 0 : round($home));
        $study = $study > 500 ? 500 : ($study < 0 ? 0 : round($study));
        // edit 20180816
        $love = ceil($love * 0.76) + 120;
        $health = ceil($health * 0.76) + 120;
        $this->career = ceil($this->career * 0.76) + 120;
        $money = ceil($money * 0.76) + 120;
        $home = ceil($home * 0.76) + 120;
        $study = ceil($study * 0.76) + 120;
        /**
         * 2022-02-14
         *  一生格局分数调整
         */
        $love = $this->resetScore($love);
        $health = $this->resetScore($health);
        $this->career = $this->resetScore($this->career);
        $money = $this->resetScore($money);
        $home = $this->resetScore($home);
        $study = $this->resetScore($study);

        $ret = [
            'love' => $love,
            'work' => $this->career,
            'health' => $health,
            'money' => $money,
            'home' => $home,
            'study' => $study,
        ];

        return $ret;
    }

    private function resetScore($score)
    {
        /**
         * 添加100的整数倍，使该值不小于260
         */
        if ($score < 260)
        {
            $diff = ceil((260 - $score) / 100);
            $score += $diff * 100;
        }
        return $score;
    }

    /**
     * 获取健康分数
     * @return float
     */
    protected function getTheHealth()
    {

        $health = 500;
        $house1 = $this->base_data['houses'][1];
        $house6 = $this->base_data['houses'][6];
        $house8 = $this->base_data['houses'][8];
        $house12 = $this->base_data['houses'][12];
        $sun = $this->base_data['planets'][0];
        $moon = $this->base_data['planets'][1];
        $merc = $this->base_data['planets'][2];
        $venu = $this->base_data['planets'][3];
        $mars = $this->base_data['planets'][4];
        $jupi = $this->base_data['planets'][5];
        $satu = $this->base_data['planets'][6];
//        $nept = $this->base_data['planets'][8];
//        $plut = $this->base_data['planets'][9];

        $house1_protect_planet = $this->base_data['planets'][$house1['protect_ancient_id']];
        $house6_protect_planet = $this->base_data['planets'][$house6['protect_ancient_id']];
        $y = 0;
        //1、	命宫
        // A 1宫有宫内星，取宫内星最大损伤值s，jiank=500-s/5;【s除以几待调节】
        if ($house1['have_planet_num'] > 0)
        {
            $s = 0;
            $bad_planet_num = 0;
            foreach ($house1['in_house_area_planet_info'] as $k => $planet)
            {
                $burn_house1 = $this->planet_power[$planet['id']]['burn'];
                if ($burn_house1 > $s) $s = $burn_house1;
                if (in_array($planet['id'], [4, 6, 8, 9])) $bad_planet_num++;
            }
            $health -= $s / 5;
            if ($this->debug) echo "1宫内最大值：-{$s}/5={$health}\n";
            // B 火土海冥落宫内，只一颗的话，火-30，土-50，一颗以上则60*星体个数
            if ($bad_planet_num == 1)
            {
                $y++;
                if ($this->debug) echo "1宫内1颗星：$bad_planet_num\n";
                if ($house1['in_house_area_planet_info'][0]['id'] == 4) $health -= 30;
                elseif ($house1['in_house_area_planet_info'][0]['id'] == 6) $health -= 50;
            } elseif ($bad_planet_num > 1)
            {
                $y++;
                $health -= 60 * $bad_planet_num;
                if ($this->debug) echo "1宫内多颗星：-60*{$bad_planet_num}={$health}\n";
            }
        }
        // C 若一宫宫内星火或土，刑冲到月亮，jiank=jiank-120，刑冲到命主星（古典）或太阳，-100（只计一次）

        if (
            ($mars['in_house_id'] == 1 && isset($mars['phase']['4-1']) && in_array($mars['phase']['4-1']['phase_e'], [9, 180]))
            || ($satu['in_house_id'] == 1 && isset($satu['phase']['6-1']) && in_array($satu['phase']['6-1']['phase_e'], [9, 180]))
        )
        {
            $y++;
            $health -= 120;
            if ($this->debug) echo "1宫内火土刑冲月亮：-120={$health}\n";
        } elseif (
            ($mars['in_house_id'] == 1 && isset($mars['phase']['4-0']) && in_array($mars['phase']['4-0']['phase_e'], [9, 180]))
            || ($satu['in_house_id'] == 1 && isset($satu['phase']['6-0']) && in_array($satu['phase']['6-0']['phase_e'], [9, 180]))
        )
        {
            $y++;
            $health -= 100;
            if ($this->debug) echo "1宫内火土刑冲到命主星（古典）或太阳：-100={$health}\n";
        }
        // D 6宫主[古典]飞入命宫健康-50，合上升则健康-50，与命主（古典）成相则- 70，与月亮成相则-80【多次计算】
        if ($house6['protect_ancient_inhouse_id'] == 1)
        {
            $y++;
            $health -= 50;
            if ($this->debug) echo "6宫主[古典]飞入命宫健康-50={$health}\n";
        }
        if (isset($house6_protect_planet['phase'][$house6['protect_ancient_id'] . '-' . ASC])
            && $house6_protect_planet['phase'][$house6['protect_ancient_id'] . '-' . ASC]['phase_e'] == 0)
        {
            $y++;
            $health -= 50;
            if ($this->debug) echo "6宫主[古典]合上升则健康-50={$health}\n";
        }
        if (isset($house6_protect_planet['phase'][$house6['protect_ancient_id'] . '-' . $house1['protect_ancient_id']]))
        {
            $y++;
            $health -= 70;
            if ($this->debug) echo "6宫主[古典]与命主（古典）成相则- 70={$health}\n";
        }
        if (isset($house6_protect_planet['phase'][$house6['protect_ancient_id'] . '-1']))
        {
            $y++;
            $health -= 80;
            if ($this->debug) echo "6宫主[古典]与月亮成相则-80={$health}\n";
        }
        // E 命主落6/8宫，jiank=jiank-命主星损伤值/2（若该命主星是太阳或月亮，则将‘命主星损伤值/2’改为‘命主星损伤值’）；若此时，本项所减值不足200，且命主与火、土或6/8宫主有刑冲，则将减值改为200；
        $f_6_8 = false;
        if (in_array($house1['protect_ancient_inhouse_id'], [6, 8]))
        {
            $y++;
            $health -= $this->planet_power[$house1_protect_planet['id']]['burn'] / 2;
            if ($this->debug) echo "命主落6/8宫，jiank=jiank-命主星损伤值{$this->planet_power[$house1_protect_planet['id']]['burn']}/2={$health}\n";
            if (in_array($house1_protect_planet['id'], [0, 1]))
            {
                $health -= $this->planet_power[$house1_protect_planet['id']]['burn'] / 2;
                if ($this->debug) echo "命主落6/8宫，jiank=jiank-命主星损伤值{$this->planet_power[$house1_protect_planet['id']]['burn']}/2={$health}\n";
            }
        } // F 若命主未落6/8宫，但与6/8宫主或宫内星刑冲，令jiank=jiank-命主星损伤值/2，（若该命主星是太阳或月亮，则将‘命主星损伤值/2’改为‘命主星损伤值’）
        elseif (!in_array($house1['protect_ancient_inhouse_id'], [6, 8]))
        {
            if (!empty($house1_protect_planet['phase']))
            {
                foreach ($house1_protect_planet['phase'] as $h1pp)
                {
                    if (
                        in_array($this->base_data['planets'][$h1pp['id']]['in_house_id'], [6, 8])
                        || $h1pp['id'] == $house6_protect_planet || $h1pp['id'] == $this->base_data['planets'][$house8['protect_ancient_id']]
                    )
                    {
                        $f_6_8 = true;
                    }
                }
            }
        }
        if ($f_6_8 === true)
        {
            $y++;
            $health -= $this->planet_power[$house1_protect_planet['id']]['burn'] / 2;
            if ($this->debug) echo "若命主未落6/8宫，但与6/8宫主或宫内星刑冲，令jiank=jiank-命主星损伤值{$this->planet_power[$house1_protect_planet['id']]['burn']}/2={$health}\n";
            if (in_array($house1_protect_planet['id'], [0, 1]))
            {
                $health -= $this->planet_power[$house1_protect_planet['id']]['burn'] / 2;
                if ($this->debug) echo "若命主未落6/8宫，但与6/8宫主或宫内星刑冲，令jiank=jiank-命主星损伤值,若该命主星是太阳或月亮{$this->planet_power[$house1_protect_planet['id']]['burn']}/2={$health}\n";
            }
        }
        // G 若命主落6宫与8宫宫内星成六分相，或命主落8宫与6宫宫内星成六分相，jiank=jiank-100
        $F_boolen = false;
        if ($house1_protect_planet['in_house_id'] == 6)
        {
            if (!empty($house1_protect_planet['phase']))
            {
                foreach ($house1_protect_planet['phase'] as $phase)
                {
                    if ($phase['phase_e'] == 60 && $this->base_data['planets'][$phase['id']]['in_house_id'] == 8)
                        $F_boolen = true;
                }
            }
        } elseif ($house1_protect_planet['in_house_id'] == 8)
        {
            if (!empty($house1_protect_planet['phase']))
            {
                foreach ($house1_protect_planet['phase'] as $phase)
                {
                    if ($phase['phase_e'] == 60 && $this->base_data['planets'][$phase['id']]['in_house_id'] == 6)
                        $F_boolen = true;
                }
            }
        }
        if ($F_boolen === true)
        {
            $y++;
            $health -= 100;
            if ($this->debug) echo "若命主落6宫与8宫宫内星成六分相，或命主落8宫与6宫宫内星成六分相，-100={$health}\n";
        }
        // H 若命主未落6/8宫且未与6/8宫主及宫内星刑冲，则jiank=jiank-命主损伤值/5
        if (!in_array($house1['protect_ancient_inhouse_id'], [6, 8]) && $f_6_8 === false)
        {
            $y++;
            $health -= $this->planet_power[$house1_protect_planet['id']]['burn'] / 2;
            if ($this->debug) echo "若命主未落6/8宫且未与6/8宫主及宫内星刑冲，则jiank=jiank-命主损伤值{$this->planet_power[$house1_protect_planet['id']]['burn']}/5={$health}\n";
        }

        // #######E 若命主落6/8宫，或6/8宫主飞1宫，或命主与6/8宫主刑冲，jiank=jiank-宫主星损伤值/2；否则，jiank=jiank-宫主星损伤值/5
        // E 若命主落6/8宫，此时若6/8宫主飞1宫，或命主与6/8宫主刑冲，jiank=jiank-命主星损伤值/2
//        if(
//            in_array($house1['protect_ancient_inhouse_id'],[6,8])
//            && (
//                $house6['protect_ancient_inhouse_id'] == 1
//                || $house8['protect_ancient_inhouse_id'] == 1
//                || (
//                    isset($house1_protect_planet['phase'][$house1['protect_ancient_id'].'-'.$house6['protect_ancient_id']])
//                    && in_array($house1_protect_planet['phase'][$house1['protect_ancient_id'].'-'.$house6['protect_ancient_id']]['phase_e'],[90,180])
//                )
//                || (
//                    isset($house1_protect_planet['phase'][$house1['protect_ancient_id'].'-'.$house8['protect_ancient_id']])
//                    && in_array($house1_protect_planet['phase'][$house1['protect_ancient_id'].'-'.$house8['protect_ancient_id']]['phase_e'],[90,180]))
//            )
//        )
//        {
//            $y++;
//            $health -= $this->planet_power[$house1['protect_ancient_id']['burn']]/2;
//            if($this->debug) echo "若命主落6/8宫，此时若6/8宫主飞1宫，或命主与6/8宫主刑冲，jiank=jiank-命主星损伤值/2;损伤值{$this->planet_power['burn'][$house1['protect_ancient_id']]}={$health}\n";
//        }


        // 2、	六宫
        // A 月在6宫内，取x=月亮受伤值；日在6宫内，取x=太阳受伤值*0.7；金水木在6宫（非命主），取x=该星受伤值*0.5；统合所有宫内星，令以上各不等于零的x相加，乘以（1-y/10）,y=加数个数
        $x = [0, 0, 0, 0, 0];
        if ($sun['in_house_id'] == 6)
        {
            $x[0] = $this->planet_power[0]['burn'] * 0.7;
        }
        if ($moon['in_house_id'] == 6)
        {
            $x[1] = $this->planet_power[1]['burn'];
        }
        if ($merc['in_house_id'] == 6 && $merc['id'] != $house1['protect_ancient_id'])
        {
            $x[2] = $this->planet_power[2]['burn'] * 0.5;
        }
        if ($venu['in_house_id'] == 6 && $venu['id'] != $house1['protect_ancient_id'])
        {
            $x[3] = $this->planet_power[3]['burn'] * 0.5;
        }
        if ($jupi['in_house_id'] == 6 && $jupi['id'] != $house1['protect_ancient_id'])
        {
            $x[5] = $this->planet_power[5]['burn'] * 0.5;
        }
        $x = array_filter($x);
        $yy = count($x);
        $sum = array_sum($x) * (1 - $yy / 10);
        if ($sum > 0)
        {
            $health -= $sum;
            if ($this->debug) echo "6宫宫内星统计：-$sum={$health}\n";
        }
        // B 火土海冥落宫内，只一颗的话，火-30，土-50，一颗以上则50*星体个数；
        // 若落6宫并冲到月亮，-150，合到月亮-120，刑到月亮-80，三分六分月亮-50（只计一次）；
        // 若冲太阳-110，合到太阳-80，刑到太阳-70（只计一次）：若冲金水-80，合金水-60，刑金水-50
        if ($house6['have_planet_num'] > 0)
        {
            $bad_planet_num = 0;
            $pk_sun = false;
            $pk_moon = false;
            foreach ($house6['in_house_area_planet_info'] as $k => $planet)
            {
                if (in_array($planet['id'], [4, 6, 7, 8, 9]))
                {
                    $bad_planet_num++;
                    $phase_planet = $this->base_data['planets'][$planet['id']]['phase'];
                    if ($pk_moon === false && isset($phase_planet[$planet['id'] . '-1']))
                    {
                        if ($phase_planet[$planet['id'] . '-1']['phase_e'] == 180)
                        {
                            $pk_moon = true;
                            $health -= 150;
                            if ($this->debug) echo "若落6宫并冲到月亮：-150={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-1']['phase_e'] == 0)
                        {
                            $pk_moon = true;
                            $health -= 120;
                            if ($this->debug) echo "若落6宫并合到月亮：-120={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-1']['phase_e'] == 90)
                        {
                            $pk_moon = true;
                            $health -= 80;
                            if ($this->debug) echo "若落6宫并刑到月亮：-80={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-1']['phase_e'] == 120
                            || $phase_planet[$planet['id'] . '-1']['phase_e'] == 60)
                        {
                            $pk_moon = true;
                            $health -= 50;
                            if ($this->debug) echo "若落6宫并三分六分月亮：-50={$health}\n";
                        }
                    }
                    if ($pk_sun === false && isset($phase_planet[$planet['id'] . '-0']))
                    {
                        if ($phase_planet[$planet['id'] . '-0']['phase_e'] == 180)
                        {
                            $pk_sun = true;
                            $health -= 110;
                            if ($this->debug) echo "若落6宫并冲到太阳：-110={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-0']['phase_e'] == 0)
                        {
                            $pk_sun = true;
                            $health -= 80;
                            if ($this->debug) echo "若落6宫并刑到太阳：-80={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-0']['phase_e'] == 90)
                        {
                            $pk_sun = true;
                            $health -= 70;
                            if ($this->debug) echo "若落6宫并刑到太阳：-70={$health}\n";
                        }
                    }
                    if (isset($phase_planet[$planet['id'] . '-2']))
                    {
                        if ($phase_planet[$planet['id'] . '-2']['phase_e'] == 180)
                        {
//                        $pk_sun = true;
                            $health -= 80;
                            if ($this->debug) echo "若落6宫并冲到水星：-80={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-2']['phase_e'] == 0)
                        {
//                        $pk_sun = true;
                            $health -= 60;
                            if ($this->debug) echo "若落6宫并合到水星：-60={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-2']['phase_e'] == 90)
                        {
//                        $pk_sun = true;
                            $health -= 50;
                            if ($this->debug) echo "若落6宫并刑到水星：-50={$health}\n";
                        }
                    }
                    if (isset($phase_planet[$planet['id'] . '-3']))
                    {
                        if ($phase_planet[$planet['id'] . '-3']['phase_e'] == 180)
                        {
//                        $pk_sun = true;
                            $health -= 80;
                            if ($this->debug) echo "若落6宫并冲到金星：-80={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-3']['phase_e'] == 0)
                        {
//                        $pk_sun = true;
                            $health -= 60;
                            if ($this->debug) echo "若落6宫并合到金星：-60={$health}\n";
                        } elseif ($phase_planet[$planet['id'] . '-3']['phase_e'] == 90)
                        {
//                        $pk_sun = true;
                            $health -= 50;
                            if ($this->debug) echo "若落6宫并刑到金星：-50={$health}\n";
                        }
                    }
                }

            }
            // B 火土海冥落宫内，只一颗的话，火-30，土-50，一颗以上则60*星体个数
            if ($bad_planet_num == 1)
            {
                if ($house6['in_house_area_planet_info'][0]['id'] == 4)
                {
                    $health -= 30;
                    if ($this->debug) echo "火落宫内，只一颗的话，火-30\n={$health}";
                } elseif ($house6['in_house_area_planet_info'][0]['id'] == 6)
                {
                    $health -= 50;
                    if ($this->debug) echo "土落宫内，只一颗的话，土-50\n={$health}";
                }
            } elseif ($bad_planet_num > 1)
            {
                $health -= 50 * $bad_planet_num;
                if ($this->debug) echo "火土海冥落宫内，一颗以上则60*星体个数={$health}\n";
            }
        }
        $health -= $this->planet_power[$house6['protect_ancient_id']]['burn'] / 4;
        if ($this->debug) echo "jiank=jiank-6宫主的受伤值/4损伤值：{$this->planet_power[$house6['protect_ancient_id']]['burn']}={$health}\n";
        // 3、	月亮/太阳
        $health -= $this->planet_power[1]['burn'] / 5;
        if ($this->debug) echo "Jiank=jiank-月亮损伤值/5；损伤值：{$this->planet_power[1]['burn']}={$health}\n";
        $health -= $this->planet_power[0]['burn'] / 6;
        if ($this->debug) echo "Jiank=jiank-太阳损伤值/5；损伤值：{$this->planet_power[0]['burn']}={$health}\n";
//        1、	计算6/8宫内所落个人星（日月金水火）个数，计为x，【-30x】
        $in_house6_8 = 0;
        if (in_array($sun['in_house_id'], [6, 8]))
        {
            $in_house6_8++;
        }
        if (in_array($moon['in_house_id'], [6, 8]))
        {
            $in_house6_8++;
        }
        if (in_array($merc['in_house_id'], [6, 8]))
        {
            $in_house6_8++;
        }
        if (in_array($venu['in_house_id'], [6, 8]))
        {
            $in_house6_8++;
        }
        if (in_array($mars['in_house_id'], [6, 8]))
        {
            $in_house6_8++;
        }
        $health -= $in_house6_8 * 30;
        if ($this->debug) echo "Jiank=jiank-6/8宫内所落个人星（日月金水火）个数，计为{$in_house6_8}，【-30x】={$health}\n";

//        2、	命宫大类BCDEFG各项中有减分的项共有y项，则令jiank=jiank*（1-y/7）
        if ($y !== 0)
        {
            $health *= (1 - $y / 7);
            if ($this->debug) echo "命宫大类BCDEFG各项中有减分的项共有y项，则令jiank=jiank*(1-{$y}/7)={$health}\n";
        }
        if (!empty($this->base_data['structure']['t_square']))
        {
            $a = $b = $c = [];
            for ($i = 0; $i < 10; $i++)
            {
                if ($i == 0 || $i == 1 || $i == $house1['protect_id'] || $i == $house1['protect_ancient_id'])
                {
                    $a[] = $i;
                }
                if ($i == $house6['protect_id'] || $i == $house6['protect_ancient_id']
                    || $i == $house8['protect_id'] || $i == $house8['protect_ancient_id']
                    || in_array($this->base_data['planets'][$i]['in_house_id'], [6, 8]))
                {
                    $b[] = $i;
                }
                if ($i == $house12['protect_id'] || $i == $house12['protect_ancient_id']
                    || $this->base_data['planets'][$i]['in_house_id'] == 12)
                {
                    $c[] = $i;
                }
            }
            if (!empty($this->base_data['structure']['t_square']))
            {
                foreach ($this->base_data['structure']['t_square'] as $t_square)
                {
                    // 1a 2b&c 3c/b
                    if (in_array($t_square[0]['id'], $a) && in_array($t_square[1]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[2]['id'], $c) || in_array($t_square[2]['id'], $b) || in_array($t_square[1]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    } // 2a 1b&c 3c/b
                    elseif (in_array($t_square[1]['id'], $a) && in_array($t_square[0]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[2]['id'], $c) || in_array($t_square[2]['id'], $b) || in_array($t_square[0]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    } // 3a 1b&c 2c/b
                    elseif (in_array($t_square[2]['id'], $a) && in_array($t_square[0]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[1]['id'], $c) || in_array($t_square[1]['id'], $b) || in_array($t_square[0]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    } // 3a 2b&c 1c/b
                    elseif (in_array($t_square[2]['id'], $a) && in_array($t_square[1]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[0]['id'], $c) || in_array($t_square[0]['id'], $b) || in_array($t_square[1]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    } // 1a 3b&c 2c/b
                    elseif (in_array($t_square[0]['id'], $a) && in_array($t_square[2]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[1]['id'], $c) || in_array($t_square[1]['id'], $b) || in_array($t_square[2]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    } // 2a 3b&c 1c/b
                    elseif (in_array($t_square[1]['id'], $a) && in_array($t_square[2]['id'], $b))
                    {
                        $health -= 40;
                        if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        if (in_array($t_square[0]['id'], $c) || in_array($t_square[0]['id'], $b) || in_array($t_square[2]['id'], $c))
                        {
                            $health -= 40;
                            if ($this->debug) echo "Jiank=jiank-40={$health}\n";
                        }
                    }
                }
            }
        }

        return $health;
    }

    /**
     * 获取事业分数
     * @return int
     */
    protected function getTheCareer()
    {
        $career = 0;
        $house1 = $this->base_data['houses'][1];
        $house6 = $this->base_data['houses'][6];
        $house8 = $this->base_data['houses'][8];
        $sun = $this->base_data['planets'][0];
        $moon = $this->base_data['planets'][1];
        $merc = $this->base_data['planets'][2];
        $venu = $this->base_data['planets'][3];
        $mars = $this->base_data['planets'][4];
        $jupi = $this->base_data['planets'][5];
        $satu = $this->base_data['planets'][6];
        $nept = $this->base_data['planets'][8];
        $plut = $this->base_data['planets'][9];

        $group_a = $group_b = $group_c = 0;
//        一、	命宫
        $house1_protect = $this->base_data['planets'][$house1['protect_id']];
        $house1_protect_ancient = $this->base_data['planets'][$house1['protect_ancient_id']];
//        1、	命主擢升或入庙或命主被接纳（包括现占古占，只计擢升或本垣接纳，下同）或命主有互容（包括现古，只计本-本，本-升，升-升，下同）【+23】，
//              若为无相位互容且互容对象为日或月再【+25】，若为无相位互容且互容对象为金或木再【+20】
        $hpo = $this->housePower(1);
        if ($hpo['walls'] == 1
            || $hpo['promote'] == 1
            || !empty($hpo['walls_accept'])
            || !empty($hpo['promote_accept'])
            || !empty($hpo['accept_each_other']))
        {
            $group_a++;
            $career += 23;
            if ($this->debug) echo "命主擢升或入庙或命主被接纳或命主有互容+23={$career}\n";
            $no_phase_sun_moon = false;
            $no_phase_venu_jupi = false;
            if (!empty($hpo['accept_each_other_by_phase']))
            {
                foreach ($hpo['accept_each_other_by_phase'] as $i => $aeobp)
                {
                    if ($aeobp == 2)
                    {
                        if ($i == 0 || $i == 1)
                        {
                            $no_phase_sun_moon = true;
                        } elseif ($i == 3 || $i == 5)
                        {
                            $no_phase_venu_jupi = true;
                        }
                    }
                }
            }
            if ($no_phase_sun_moon === true)
            {
                $career += 25;
                if ($this->debug) echo "若为无相位互容且互容对象为日或月再+25={$career}\n";
            }
            if ($no_phase_venu_jupi === true)
            {
                $career += 20;
                if ($this->debug) echo "若为无相位互容且互容对象为金或木再+20={$career}\n";
            }
        }
//        2、	命主与太阳有相位【+28】，若此时为日生盘【+10】，若与太阳接纳或互容【+15】，若是同度相位【+8】；
        if (isset($house1_protect['phase'][$house1_protect['id'] . '-0'])
            || isset($house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-0']))
        {
            $group_b++;
            $career += 28;
            if ($this->debug) echo "命主星与太阳有相位+28={$career}\n";
            if ($sun['in_house_id'] > 6)
            {
                $career += 10;
                if ($this->debug) echo "若此时为日生盘【+10】={$career}\n";
            }
            if ((!empty($hpo['walls_accept']) && isset($hpo['walls_accept'][0]))
                || (!empty($hpo['promote_accept']) && isset($hpo['promote_accept'][0]))
                || (!empty($hpo['accept_each_other']) && isset($hpo['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "若与太阳接纳或互容【+15】={$career}\n";
            }
            if (
                (isset($house1_protect['phase'][$house1_protect['id'] . '-0'])
                    && $house1_protect['phase'][$house1_protect['id'] . '-0']['phase_orb'] <= 1)
                || (isset($house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-0'])
                    && $house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-0']['phase_orb'] <= 1)
            )
            {
                $career += 8;
                if ($this->debug) echo "若是同度相位【+8】={$career}\n";
            }
        }
//        3、	命主与月亮有相位【+25】，若此时为夜生盘【+10】，若与月亮接纳或互容【+15】，若是同度相位【+8】；
        if (isset($house1_protect['phase'][$house1_protect['id'] . '-1'])
            || isset($house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-1']))
        {
            $group_b++;
            $career += 25;
            if ($this->debug) echo "命主与月亮有相位+28={$career}\n";
            if ($moon['in_house_id'] < 7)
            {
                $career += 10;
                if ($this->debug) echo "若此时为夜生盘【+10】={$career}\n";
            }
            if ((!empty($hpo['walls_accept']) && isset($hpo['walls_accept'][0]))
                || (!empty($hpo['promote_accept']) && isset($hpo['promote_accept'][0]))
                || (!empty($hpo['accept_each_other']) && isset($hpo['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "若与月亮接纳或互容【+15】={$career}\n";
            }
            if (
                (isset($house1_protect['phase'][$house1_protect['id'] . '-1'])
                    && $house1_protect['phase'][$house1_protect['id'] . '-1']['phase_orb'] <= 1)
                || (isset($house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-1'])
                    && $house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-1']['phase_orb'] <= 1)
            )
            {
                $career += 8;
                if ($this->debug) echo "若是同度相位【+8】={$career}\n";
            }
        }
//        4、	太阳落命宫【+29】，若此时太阳合上升【+25】，太阳擢升或入庙或被接纳互容【+18】
        if ($sun['in_house_id'] == 1)
        {
            $group_b++;
            $career += 29;
            if ($this->debug) echo "太阳落命宫【+29】={$career}\n";
            if (isset($sun['phase']['0-' . ASC]) && $sun['phase']['0-' . ASC]['phase_e'] == 0)
            {
                $career += 25;
                if ($this->debug) echo "若此时太阳合上升【+25】={$career}\n";
            }
            $pp_sun = $this->PlanetPower(0);
            if ($pp_sun['walls'] == 1 || $pp_sun['promote'] == 1
                || !empty($pp_sun['walls_accept'])
                || !empty($pp_sun['promote_accept'])
                || !empty($pp_sun['accept_each_other'])
            )
            {
                $career += 18;
                if ($this->debug) echo "太阳擢升或入庙或被接纳互容【+18】={$career}\n";
            }
        }
//        5、	月亮落命宫【+19】，若此时月亮合上升【+16】，月亮擢升或入庙或被接纳互容【+18】
        if ($moon['in_house_id'] == 1)
        {
            $group_b++;
            $career += 19;
            if ($this->debug) echo "月亮落命宫【+19】={$career}\n";
            if (isset($moon['phase']['0-' . ASC]) && $moon['phase']['0-' . ASC]['phase_e'] == 0)
            {
                $career += 16;
                if ($this->debug) echo "若此时月亮合上升【+16】={$career}\n";
            }
            $pp_moon = $this->PlanetPower(0);
            if ($pp_moon['walls'] == 1 || $pp_moon['promote'] == 1
                || !empty($pp_moon['walls_accept'])
                || !empty($pp_moon['promote_accept'])
                || !empty($pp_moon['accept_each_other'])
            )
            {
                $career += 18;
                if ($this->debug) echo "月亮擢升或入庙或被接纳互容【+18】={$career}\n";
            }
        }
//        6、	太阳与命宫宫内星成相（多相位也只计一次）【+25】，若相位中有互容接纳【+15】，若有同度相位【+8】
        $sun_house1_phase = false;
        if (!empty($sun['phase']))
        {
            foreach ($sun['phase'] as $s_phase)
            {
                if ($s_phase['id'] > 9) continue;
                $s_pp = $this->PlanetPower($s_phase['id']);
                if ($this->base_data['planets'][$s_phase['id']]['in_house_id'] == 1)
                {
                    $sun_house1_phase = true;
                }
                if (
                    (!empty($s_pp['walls_accept']) && isset($s_pp['walls_accept'][$s_phase['id']]))
                    || (!empty($s_pp['promote_accept']) && isset($s_pp['promote_accept'][$s_phase['id']]))
                    || (!empty($s_pp['accept_each_other']) && isset($s_pp['accept_each_other'][$s_phase['id']]))
                )
                {
                    $group_b++;
                    $career += 15;
                    if ($this->debug) echo "若相位中有互容接纳【+15】={$career}\n";
                }
                if ($s_phase['phase_orb'] <= 1)
                {
                    $group_b++;
                    $career += 8;
                    if ($this->debug) echo "若是同度相位【+8】={$career}\n";
                }
            }
        }

        if ($sun_house1_phase === true)
        {
            $group_b++;
            $career += 25;
            if ($this->debug) echo "太阳与命宫宫内星成相【+25】={$career}\n";
        }
//        7、	月亮与命宫宫内星成相（多相位也只计一次）【+16】，若相位中有互容接纳【+13】，若有同度相位【+7】
        $moon_house1_phase = false;
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $m_phase)
            {
                if ($m_phase['id'] > 9) continue;
                $m_pp = $this->PlanetPower($m_phase['id']);
                if ($this->base_data['planets'][$m_phase['id']]['in_house_id'] == 1)
                {
                    $moon_house1_phase = true;
                }
                if (
                    (!empty($m_pp['walls_accept']) && isset($m_pp['walls_accept'][$m_phase['id']]))
                    || (!empty($m_pp['promote_accept']) && isset($m_pp['promote_accept'][$m_phase['id']]))
                    || (!empty($m_pp['accept_each_other']) && isset($m_pp['accept_each_other'][$m_phase['id']]))
                )
                {
                    $group_b++;
                    $career += 13;
                    if ($this->debug) echo "若相位中有互容接纳【+13】={$career}\n";
                }
                if ($m_phase['phase_orb'] <= 1)
                {
                    $group_b++;
                    $career += 7;
                    if ($this->debug) echo "若是同度相位【+7】={$career}\n";
                }
            }
        }
        if ($moon_house1_phase === true)
        {
            $group_b++;
            $career += 16;
            if ($this->debug) echo "月亮与命宫宫内星成相【+16】={$career}\n";
        }
//        8、	升狮子【+20】
        if ($this->base_data['planets'][ASC]['in_sign_id'] == 5)
        {
            $group_b++;
            $career += 20;
            if ($this->debug) echo "升狮子【+20】={$career}\n";
        }
//        9、	升巨蟹【+15】
        if ($this->base_data['planets'][ASC]['in_sign_id'] == 4)
        {
            $group_b++;
            $career += 15;
            if ($this->debug) echo "升巨蟹【+15】={$career}\n";
        }
//        10、	命主与金星有相位【+17】，若此时与金星有接纳或互容【+15】，若为同度相位【+6】
        if (isset($venu['phase']['3-' . $house1_protect['id']]))
        {
            $group_c++;
            $career += 17;
            if ($this->debug) echo "命主与金星有相位【+17】={$career}\n";
            $venu_pp = $this->PlanetPower(3);
            if (
                (!empty($venu_pp['walls_accept']) && isset($venu_pp['walls_accept'][$house1_protect['id']]))
                || (!empty($venu_pp['promote_accept']) && isset($venu_pp['promote_accept'][$house1_protect['id']]))
                || (!empty($venu_pp['accept_each_other']) && isset($venu_pp['accept_each_other'][$house1_protect['id']]))
            )
            {
                $career += 15;
                if ($this->debug) echo "命主与金星有相位,若相位中有互容接纳【+15】={$career}\n";
            }
            if ($venu['phase']['3-' . $house1_protect['id']]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "命主与金星有相位【+6】={$career}\n";
            }
        }
        if (isset($venu['phase']['3-' . $house1_protect_ancient['id']]))
        {
            $group_c++;
            $career += 17;
            if ($this->debug) echo "命主与金星有相位【+17】={$career}\n";
            $venu_pp = $this->PlanetPower(3);
            if (
                (!empty($venu_pp['walls_accept']) && isset($venu_pp['walls_accept'][$house1_protect_ancient['id']]))
                || (!empty($venu_pp['promote_accept']) && isset($venu_pp['promote_accept'][$house1_protect_ancient['id']]))
                || (!empty($venu_pp['accept_each_other']) && isset($venu_pp['accept_each_other'][$house1_protect_ancient['id']]))
            )
            {
                $career += 15;
                if ($this->debug) echo "命主与金星有相位,若相位中有互容接纳【+15】={$career}\n";
            }
            if ($venu['phase']['3-' . $house1_protect_ancient['id']]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "命主与金星有相位【+6】={$career}\n";
            }

        }
//        11、	命主与木星有相位【+21】，若此时与木星有接纳或互容【+15】，若为同度相位【+6】
        if (isset($venu['phase']['3-' . $house1_protect['id']]))
        {
            $group_c++;
            $career += 21;
            if ($this->debug) echo "命主与木星有相位【+21】={$career}\n";
            $venu_pp = $this->PlanetPower(3);
            if (
                (!empty($venu_pp['walls_accept']) && isset($venu_pp['walls_accept'][$house1_protect['id']]))
                || (!empty($venu_pp['promote_accept']) && isset($venu_pp['promote_accept'][$house1_protect['id']]))
                || (!empty($venu_pp['accept_each_other']) && isset($venu_pp['accept_each_other'][$house1_protect['id']]))
            )
            {
                $career += 15;
                if ($this->debug) echo "命主与木星有相位,若相位中有互容接纳【+15】={$career}\n";
            }
            if ($venu['phase']['3-' . $house1_protect['id']]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "若为同度相位【+6】={$career}\n";
            }
        }
        if (isset($venu['phase']['3-' . $house1_protect_ancient['id']]))
        {
            $group_c++;
            $career += 21;
            if ($this->debug) echo "命主与木星有相位【+21】={$career}\n";
            $venu_pp = $this->PlanetPower(3);
            if (
                (!empty($venu_pp['walls_accept']) && isset($venu_pp['walls_accept'][$house1_protect_ancient['id']]))
                || (!empty($venu_pp['promote_accept']) && isset($venu_pp['promote_accept'][$house1_protect_ancient['id']]))
                || (!empty($venu_pp['accept_each_other']) && isset($venu_pp['accept_each_other'][$house1_protect_ancient['id']]))
            )
            {
                $career += 15;
                if ($this->debug) echo "命主与木星有相位,若相位中有互容接纳【+15】={$career}\n";
            }
            if ($venu['phase']['3-' . $house1_protect_ancient['id']]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "若为同度相位【+6】={$career}\n";
            }

        }
//        12、	金星落命宫【+18】，若此时金星合上升【+17】，金星擢升或入庙或被接纳互容【+15】
        if ($venu['in_house_id'] == 1)
        {
            $group_c++;
            $career += 18;
            if ($this->debug) echo "金星落命宫【+18】={$career}\n";
            if (isset($venu['phase']['3-' . ASC]) && $venu['phase']['3-' . ASC]['phase_e'] == 0)
            {
                $career += 17;
                if ($this->debug) echo "金星落命宫,若此时金星合上升【+17】={$career}\n";
            }
            $venu_pp = $this->PlanetPower(3);
            if (
                $venu_pp['walls'] == 1 || $venu_pp['promote'] == 1
                || !empty($venu_pp['walls_accept'])
                || !empty($venu_pp['promote_accept'])
                || !empty($venu_pp['accept_each_other'])
            )
            {
                $career += 17;
                if ($this->debug) echo "命主与木星有相位,若相位中有互容接纳【+17】={$career}\n";
            }
        }
//        13、	木星落命宫【+23】，若此时木星合上升【+21】，木星擢升或入庙或被接纳互容【+18】
        if ($jupi['in_house_id'] == 1)
        {
            $group_c++;
            $career += 23;
            if ($this->debug) echo "木星落命宫【+23】={$career}\n";
            if (isset($jupi['phase']['3-' . ASC]) && $jupi['phase']['3-' . ASC]['phase_e'] == 0)
            {
                $career += 21;
                if ($this->debug) echo "木星落命宫,若此时木星合上升【+21】={$career}\n";
            }
            $venu_pp = $this->PlanetPower(3);
            if (
                $venu_pp['walls'] == 1 || $venu_pp['promote'] == 1
                || !empty($venu_pp['walls_accept'])
                || !empty($venu_pp['promote_accept'])
                || !empty($venu_pp['accept_each_other'])
            )
            {
                $career += 17;
                if ($this->debug) echo "木星擢升或入庙或被接纳互容【+17】={$career}\n";
            }
        }
//        14、	金星与命宫宫内星成相（多相位也只计一次）【+16】，若相位中有互容接纳【+13】，若有同度相位【+7】
        $venu_house1_phase = false;
        if (!empty($venu['phase']))
        {
            foreach ($venu['phase'] as $m_phase)
            {
                if ($m_phase['id'] > 9) continue;
                $m_pp = $this->PlanetPower($m_phase['id']);
                if ($this->base_data['planets'][$m_phase['id']]['in_house_id'] == 1)
                {
                    $venu_house1_phase = true;
                }
                if (
                    (!empty($m_pp['walls_accept']) && isset($m_pp['walls_accept'][$m_phase['id']]))
                    || (!empty($m_pp['promote_accept']) && isset($m_pp['promote_accept'][$m_phase['id']]))
                    || (!empty($m_pp['accept_each_other']) && isset($m_pp['accept_each_other'][$m_phase['id']]))
                )
                {
                    $group_c++;
                    $career += 13;
                    if ($this->debug) echo "金星与命宫宫内星成相,若相位中有互容接纳【+13】={$career}\n";
                }
                if ($m_phase['phase_orb'] <= 1)
                {
                    $group_c++;
                    $career += 7;
                    if ($this->debug) echo "金星与命宫宫内星成相,若是同度相位【+7】={$career}\n";
                }
            }
        }
        if ($venu_house1_phase === true)
        {
            $group_c++;
            $career += 16;
            if ($this->debug) echo "金星与命宫宫内星成相【+16】={$career}\n";
        }
//        15、	木与命宫宫内星成相（多相位也只计一次）【+19】，若相位中有互容接纳【+15】，若有同度相位【+9】
        $jupi_house1_phase = false;
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $m_phase)
            {
                if ($m_phase['id'] > 9) continue;
                $m_pp = $this->PlanetPower($m_phase['id']);
                if ($this->base_data['planets'][$m_phase['id']]['in_house_id'] == 1)
                {
                    $jupi_house1_phase = true;
                }
                if (
                    (!empty($m_pp['walls_accept']) && isset($m_pp['walls_accept'][$m_phase['id']]))
                    || (!empty($m_pp['promote_accept']) && isset($m_pp['promote_accept'][$m_phase['id']]))
                    || (!empty($m_pp['accept_each_other']) && isset($m_pp['accept_each_other'][$m_phase['id']]))
                )
                {
                    $group_c++;
                    $career += 15;
                    if ($this->debug) echo "木与命宫宫内星成相,若相位中有互容接纳【+15】={$career}\n";
                }
                if ($m_phase['phase_orb'] <= 1)
                {
                    $group_c++;
                    $career += 9;
                    if ($this->debug) echo "木与命宫宫内星成相,若是同度相位【+9】={$career}\n";
                }
            }
        }
        if ($jupi_house1_phase === true)
        {
            $group_c++;
            $career += 19;
            if ($this->debug) echo "木与命宫宫内星成相【+19】={$career}\n";
        }
//        16、	上升是金牛天秤【+12】
        if (in_array($this->base_data['planets'][ASC]['in_sign_id'], [2, 7]))
        {
            $group_c++;
            $career += 12;
            if ($this->debug) echo "上升是金牛天秤【+12】={$career}\n";
        }
//        17、	上升是射手双鱼【+15】
        if (in_array($this->base_data['planets'][ASC]['in_sign_id'], [9, 12]))
        {
            $group_c++;
            $career += 15;
            if ($this->debug) echo "上升是金牛天秤【+15】={$career}\n";
        }
//        18、	令1为a组，2-9为b组，10-17为c组，若其中三组均有加分，则【+40】，若其中两组有加分则【+28】
        if ($group_a > 0 && $group_b > 0 && $group_c > 0)
        {
            $career += 40;
            if ($this->debug) echo "令1为a组，2-9为b组，10-17为c组，若其中三组均有加分【+40】={$career}\n";
        } elseif (
            ($group_a > 0 && $group_b > 0)
            || ($group_a > 0 && $group_c > 0)
            || ($group_c > 0 && $group_b > 0)
        )
        {
            $career += 28;
            if ($this->debug) echo "令1为a组，2-9为b组，10-17为c组，若其中两组有加分则【+28】={$career}\n";
        }
//        二、	事业宫
        $group2_a = $group2_b = $group2_c = $group2_d = $group2_e = 0;
        $house10 = $this->base_data['houses'][10];
//        1、	【+活跃度/5】
        $career += $this->house_score[9]['active'] / 5;
        if ($this->debug) echo "事业宫+活跃度{$this->house_score[9]['active']}/5={$career}\n";
//        2、	十宫主擢升或入庙或被接纳（包括现占古占，只计擢升或本垣接纳，下同）或十宫主有互容（包括现古，只计本-本，本-升，升-升，下同）【+23】，若为无相位互容且互容对象为日或月再【+25】，若为无相位互容且互容对象为金或木再【+20】
        $house10_protect = $house10['protect_id'];
        $house10_protect_ancient = $house10['protect_ancient_id'];
        $hopo = $this->planetPower($house10_protect);
        if ($hopo['walls'] == 1
            || $hopo['promote'] == 1
            || !empty($hopo['walls_accept'])
            || !empty($hopo['promote_accept'])
            || !empty($hopo['accept_each_other']))
        {
            $career += 23;
            if ($this->debug) echo "十宫主擢升或入庙或被接纳或十宫主有互容+23={$career}\n";
            $no_phase_sun_moon = false;
            $no_phase_venu_jupi = false;
            if (!empty($hopo['accept_each_other_by_phase']))
            {
                foreach ($hpo['accept_each_other_by_phase'] as $i => $aeobp)
                {
                    if ($aeobp == 2)
                    {
                        if ($i == 0 || $i == 1)
                        {
                            $no_phase_sun_moon = true;
                        } elseif ($i == 3 || $i == 5)
                        {
                            $no_phase_venu_jupi = true;
                        }
                    }
                }
            }
            if ($no_phase_sun_moon === true)
            {
                $career += 25;
                if ($this->debug) echo "若为无相位互容且互容对象为日或月再+25={$career}\n";
            }
            if ($no_phase_venu_jupi === true)
            {
                $career += 20;
                if ($this->debug) echo "若为无相位互容且互容对象为金或木再+20={$career}\n";
            }
        }
        if ($house10_protect != $house10_protect_ancient)
        {
            $hopo_ancient = $this->housePower($house10_protect_ancient);
            if ($hopo_ancient['walls'] == 1
                || $hopo_ancient['promote'] == 1
                || !empty($hopo_ancient['walls_accept'])
                || !empty($hopo_ancient['promote_accept'])
                || !empty($hopo_ancient['accept_each_other']))
            {
                $group2_a++;
                $career += 23;
                if ($this->debug) echo "十宫主擢升或入庙或被接纳或十宫主有互容+23={$career}\n";
                $no_phase_sun_moon = false;
                $no_phase_venu_jupi = false;
                if (!empty($hopo_ancient['accept_each_other_by_phase']))
                {
                    foreach ($hpo['accept_each_other_by_phase'] as $i => $aeobp)
                    {
                        if ($aeobp == 2)
                        {
                            if ($i == 0 || $i == 1)
                            {
                                $no_phase_sun_moon = true;
                            } elseif ($i == 3 || $i == 5)
                            {
                                $no_phase_venu_jupi = true;
                            }
                        }
                    }
                }
                if ($no_phase_sun_moon === true)
                {
                    $career += 25;
                    if ($this->debug) echo "若为无相位互容且互容对象为日或月再+25={$career}\n";
                }
                if ($no_phase_venu_jupi === true)
                {
                    $career += 20;
                    if ($this->debug) echo "若为无相位互容且互容对象为金或木再+20={$career}\n";
                }
            }
        }
//        3、	十宫主与太阳有相位【+28】，若此时为日生盘【+10】，若与太阳接纳或互容【+15】，若是同度相位【+8】；
        if (!empty($sun['phase']) && isset($sun['phase']['0-' . $house10_protect]))
        {
            $group2_b++;
            $career += 28;
            if ($this->debug) echo "十宫主与太阳有相位+28={$career}\n";
            if ($sun['in_house_id'] > 6)
            {
                $career += 10;
                if ($this->debug) echo "十宫主与太阳有相位,若此时为日生盘+10={$career}\n";
            }
            $h10p = $this->housePower(10);
            if ((!empty($h10p['walls_accept']) && isset($h10p['walls_accept'][0]))
                || (!empty($h10p['promote_accept']) && isset($h10p['promote_accept'][0]))
                || (!empty($h10p['accept_each_other']) && isset($h10p['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "十宫主与太阳有相位,若与太阳接纳或互容【+15】={$career}\n";
            }
            if ($sun['phase']['0-' . $house10_protect]['phase_orb'] < 1)
            {
                $career += 8;
                if ($this->debug) echo "十宫主与太阳有相位,若是同度相位+8={$career}\n";
            }
        }
//        4、	十宫主与月亮有相位【+25】，若此时为夜生盘【+10】，若与月亮接纳或互容【+15】，若是同度相位【+8】；
        if (!empty($moon['phase']) && isset($moon['phase']['1-' . $house10_protect]))
        {
            $group2_b++;
            $career += 25;
            if ($this->debug) echo "十宫主与月亮有相位+25={$career}\n";
            if ($moon['in_house_id'] > 6)
            {
                $career += 10;
                if ($this->debug) echo "十宫主与月亮有相位,若此时为日生盘+10={$career}\n";
            }
            $h10p = $this->housePower(10);
            if ((!empty($h10p['walls_accept']) && isset($h10p['walls_accept'][0]))
                || (!empty($h10p['promote_accept']) && isset($h10p['promote_accept'][0]))
                || (!empty($h10p['accept_each_other']) && isset($h10p['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "十宫主与月亮有相位,若与月亮接纳或互容【+15】={$career}\n";
            }
            if ($moon['phase']['1-' . $house10_protect]['phase_orb'] < 1)
            {
                $career += 8;
                if ($this->debug) echo "十宫主与月亮有相位,若是同度相位+8={$career}\n";
            }
        }
//        5、	太阳落十宫【+29】，若此时太阳合MC【+25】，太阳擢升或入庙或被接纳互容【+18】
        if ($sun['in_house_id'] == 10)
        {
            $group2_b++;
            $career += 29;
            if ($this->debug) echo "太阳落十宫+29={$career}\n";
            if (!empty($sun['phase']) && isset($sun['phase']['0-' . MC]))
            {
                $career += 25;
                if ($this->debug) echo "太阳落十宫，若此时太阳合MC+25={$career}\n";
            }
            $sun_hp = $this->PlanetPower(0);
            if (!empty($sun_hp['walls_accept']) || !empty($sun_hp['promote_accept']) || !empty($sun_hp['accept_each_other']))
            {
                $career += 15;
                if ($this->debug) echo "太阳落十宫，若相位中有互容接纳【+15】={$career}\n";
            }
        }
//        6、	月亮落十宫【+19】，若此时月亮合MC【+16】，月亮擢升或入庙或被接纳互容【+18】
        if ($moon['in_house_id'] == 10)
        {
            $group2_b++;
            $career += 19;
            if ($this->debug) echo "月亮落十宫+19={$career}\n";
            if (!empty($moon['phase']) && isset($moon['phase']['0-' . MC]))
            {
                $career += 16;
                if ($this->debug) echo "月亮落十宫,若此时月亮合MC+16={$career}\n";
            }
            $moon_hp = $this->PlanetPower(1);
            if (!empty($moon_hp['walls_accept']) || !empty($moon_hp['promote_accept']) || !empty($moon_hp['accept_each_other']))
            {
                $career += 18;
                if ($this->debug) echo "月亮落十宫,月亮擢升或入庙或被接纳互容【+18】={$career}\n";
            }
        }
//        7、	太阳与十宫宫内星成相（多相位也只计一次）【+25】，若相位中有互容接纳【+15】，若有同度相位【+8】
        $sun_house10_phase = false;
        if (!empty($sun['phase']))
        {
            foreach ($sun['phase'] as $s_phase)
            {
                if ($s_phase['id'] > 9) continue;
                if ($this->base_data['planets'][$s_phase['id']]['in_house_id'] == 10)
                {
                    $sun_house10_phase = true;
                    $s_pp = $this->PlanetPower($s_phase['id']);

                    if (
                        (!empty($s_pp['walls_accept']) && isset($s_pp['walls_accept'][$s_phase['id']]))
                        || (!empty($s_pp['promote_accept']) && isset($s_pp['promote_accept'][$s_phase['id']]))
                        || (!empty($s_pp['accept_each_other']) && isset($s_pp['accept_each_other'][$s_phase['id']]))
                    )
                    {
                        $group2_b++;
                        $career += 15;
                        if ($this->debug) echo "太阳与十宫宫内星成相,若相位中有互容接纳【+15】={$career}\n";
                    }
                    if ($s_phase['phase_orb'] <= 1)
                    {
                        $group2_b++;
                        $career += 8;
                        if ($this->debug) echo "太阳与十宫宫内星成相,若是同度相位【+8】={$career}\n";
                    }
                }

            }
        }

        if ($sun_house10_phase === true)
        {
            $group2_b++;
            $career += 25;
            if ($this->debug) echo "太阳与十宫宫内星成相【+25】={$career}\n";
        }
//        8、	月亮与十宫宫内星成相（多相位也只计一次）【+16】，若相位中有互容接纳【+13】，若有同度相位【+7】
        $moon_house10_phase = false;
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $s_phase)
            {
                if ($s_phase['id'] > 9) continue;
                if ($this->base_data['planets'][$s_phase['id']]['in_house_id'] == 10)
                {
                    $moon_house10_phase = true;
                    $s_pp = $this->PlanetPower($s_phase['id']);

                    if (
                        (!empty($s_pp['walls_accept']) && isset($s_pp['walls_accept'][$s_phase['id']]))
                        || (!empty($s_pp['promote_accept']) && isset($s_pp['promote_accept'][$s_phase['id']]))
                        || (!empty($s_pp['accept_each_other']) && isset($s_pp['accept_each_other'][$s_phase['id']]))
                    )
                    {
                        $group2_b++;
                        $career += 13;
                        if ($this->debug) echo "月亮与十宫宫内星成相,若相位中有互容接纳【+13】={$career}\n";
                    }
                    if ($s_phase['phase_orb'] <= 1)
                    {
                        $group2_b++;
                        $career += 7;
                        if ($this->debug) echo "月亮与十宫宫内星成相,若是同度相位【+7】={$career}\n";
                    }
                }

            }
        }
        if ($moon_house10_phase === true)
        {
            $group2_b++;
            $career += 16;
            if ($this->debug) echo "月亮与十宫宫内星成相【+16】={$career}\n";
        }
//        9、	中天狮子【+20】
        if ($this->base_data['planets'][MC]['in_sign_id'] == 5)
        {
            $group2_b++;
            $career += 20;
            if ($this->debug) echo "中天狮子【+20】={$career}\n";
        }
//        10、	中天巨蟹【+15】
        if ($this->base_data['planets'][MC]['in_sign_id'] == 5)
        {
            $group2_b++;
            $career += 15;
            if ($this->debug) echo "中天巨蟹【+15】={$career}\n";
        }
//        11、	十宫主与金星有相位【+17】，若此时与金星有接纳或互容【+15】，若为同度相位【+6】
        if (!empty($venu['phase']) && isset($venu['phase']['0-' . $house10_protect]))
        {
            $group2_c++;
            $career += 17;
            if ($this->debug) echo "十宫主与金星有相位+17={$career}\n";
            $h10p = $this->housePower(10);
            if ((!empty($h10p['walls_accept']) && isset($h10p['walls_accept'][0]))
                || (!empty($h10p['promote_accept']) && isset($h10p['promote_accept'][0]))
                || (!empty($h10p['accept_each_other']) && isset($h10p['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "十宫主与金星有相位,若此时与金星有接纳或互容【+15】={$career}\n";
            }
            if ($venu['phase']['3-' . $house10_protect]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "十宫主与金星有相位,若是同度相位+6={$career}\n";
            }
        }
//        12、	十宫主与木星有相位【+21】，若此时与木星有接纳或互容【+15】，若为同度相位【+6】
        if (!empty($jupi['phase']) && isset($jupi['phase']['0-' . $house10_protect]))
        {
            $group2_c++;
            $career += 21;
            if ($this->debug) echo "十宫主与木星有相位+21={$career}\n";
            $h10p = $this->housePower(10);
            if ((!empty($h10p['walls_accept']) && isset($h10p['walls_accept'][0]))
                || (!empty($h10p['promote_accept']) && isset($h10p['promote_accept'][0]))
                || (!empty($h10p['accept_each_other']) && isset($h10p['accept_each_other'][0])))
            {
                $career += 15;
                if ($this->debug) echo "十宫主与木星有相位,若此时与金星有接纳或互容【+15】={$career}\n";
            }
            if ($jupi['phase']['5-' . $house10_protect]['phase_orb'] < 1)
            {
                $career += 6;
                if ($this->debug) echo "十宫主与木星有相位,若是同度相位+6={$career}\n";
            }
        }
//        13、	金星落十宫【+18】，若此时金星合MC【+17】，金星擢升或入庙或被接纳互容【+15】
        if ($venu['in_house_id'] == 10)
        {
            $group2_c++;
            $career += 18;
            if ($this->debug) echo "金星落十宫+18={$career}\n";
            if (!empty($venu['phase']) && isset($venu['phase']['0-' . MC]))
            {
                $career += 17;
                if ($this->debug) echo "金星落十宫,若此时月亮合MC+17={$career}\n";
            }
            $venu_hp = $this->PlanetPower(1);
            if (!empty($venu_hp['walls_accept']) || !empty($venu_hp['promote_accept']) || !empty($venu_hp['accept_each_other']))
            {
                $career += 15;
                if ($this->debug) echo "金星落十宫,金星擢升或入庙或被接纳互容【+15】={$career}\n";
            }
        }
//        14、	木星落十宫【+23】，若此时木星合MC【+21】，木星擢升或入庙或被接纳互容【+18】
        if ($jupi['in_house_id'] == 10)
        {
            $group2_c++;
            $career += 23;
            if ($this->debug) echo "木星落十宫+23={$career}\n";
            if (!empty($jupi['phase']) && isset($jupi['phase']['0-' . MC]))
            {
                $career += 21;
                if ($this->debug) echo "木星落十宫,若此时月亮合MC+21={$career}\n";
            }
            $jupi_hp = $this->PlanetPower(1);
            if (!empty($jupi_hp['walls_accept']) || !empty($jupi_hp['promote_accept']) || !empty($jupi_hp['accept_each_other']))
            {
                $career += 18;
                if ($this->debug) echo "木星落十宫,月亮擢升或入庙或被接纳互容【+18】={$career}\n";
            }
        }
//        15、	金星与十宫宫内星成相（多相位也只计一次）【+16】，若相位中有互容接纳【+13】，若有同度相位【+7】
        $venu_house10_phase = false;
        if (!empty($venu['phase']))
        {
            foreach ($venu['phase'] as $s_phase)
            {
                if ($s_phase['id'] > 9) continue;
                if ($this->base_data['planets'][$s_phase['id']]['in_house_id'] == 10)
                {
                    $venu_house10_phase = true;
                    $s_pp = $this->PlanetPower($s_phase['id']);

                    if (
                        (!empty($s_pp['walls_accept']) && isset($s_pp['walls_accept'][$s_phase['id']]))
                        || (!empty($s_pp['promote_accept']) && isset($s_pp['promote_accept'][$s_phase['id']]))
                        || (!empty($s_pp['accept_each_other']) && isset($s_pp['accept_each_other'][$s_phase['id']]))
                    )
                    {
                        $group2_c++;
                        $career += 13;
                        if ($this->debug) echo "金星与十宫宫内星成相,若相位中有互容接纳【+13】={$career}\n";
                    }
                    if ($s_phase['phase_orb'] <= 1)
                    {
                        $group2_c++;
                        $career += 7;
                        if ($this->debug) echo "金星与十宫宫内星成相,若是同度相位【+7】={$career}\n";
                    }
                }

            }
        }

        if ($venu_house10_phase === true)
        {
            $group2_c++;
            $career += 16;
            if ($this->debug) echo "金星与十宫宫内星成相【+16】={$career}\n";
        }
//        16、	木星与十宫宫内星成相（多相位也只计一次）【+19】，若相位中有互容接纳【+15】，若有同度相位【+9】
        $jupi_house10_phase = false;
        if (!empty($jupi['phase']))
        {
            foreach ($jupi['phase'] as $s_phase)
            {
                if ($s_phase['id'] > 9) continue;
                if ($this->base_data['planets'][$s_phase['id']]['in_house_id'] == 10)
                {
                    $jupi_house10_phase = true;
                    $s_pp = $this->PlanetPower($s_phase['id']);

                    if (
                        (!empty($s_pp['walls_accept']) && isset($s_pp['walls_accept'][$s_phase['id']]))
                        || (!empty($s_pp['promote_accept']) && isset($s_pp['promote_accept'][$s_phase['id']]))
                        || (!empty($s_pp['accept_each_other']) && isset($s_pp['accept_each_other'][$s_phase['id']]))
                    )
                    {
                        $group2_c++;
                        $career += 15;
                        if ($this->debug) echo "木星与十宫宫内星成相,若相位中有互容接纳【+15】={$career}\n";
                    }
                    if ($s_phase['phase_orb'] <= 1)
                    {
                        $group2_c++;
                        $career += 9;
                        if ($this->debug) echo "木星与十宫宫内星成相,若是同度相位【+9】={$career}\n";
                    }
                }

            }
        }

        if ($jupi_house10_phase === true)
        {
            $group2_c++;
            $career += 19;
            if ($this->debug) echo "月亮与十宫宫内星成相【+19】={$career}\n";
        }
//        17、	中天是金牛天秤【+12】
        if (in_array($this->base_data['planets'][MC]['in_sign_id'], [2, 7]))
        {
            $group2_c++;
            $career += 12;
            if ($this->debug) echo "中天是金牛天秤【+12】={$career}\n";
        }
//        18、	中天是射手双鱼【+15】
        if (in_array($this->base_data['planets'][MC]['in_sign_id'], [9, 12]))
        {
            $group2_c++;
            $career += 15;
            if ($this->debug) echo "中天是射手双鱼【+15】={$career}\n";
        }

//        19、	十宫主落命宫【+23】，若此时十宫主合上升【+15】
        if ($this->base_data['planets'][$house10_protect]['in_house_id'] == 1)
        {
            $career += 23;
            if ($this->debug) echo "十宫主落命宫【+23】={$career}\n";
            if (!empty($this->base_data['planets'][$house10_protect]['phase'])
                && isset($this->base_data['planets'][$house10_protect]['phase'][$house10_protect . '-' . ASC]))
            {
                $group2_d++;
                $career += 15;
                if ($this->debug) echo "十宫主落命宫,若此时十宫主合上升【+15】={$career}\n";
            }
        }
        if ($this->base_data['planets'][$house10_protect_ancient]['in_house_id'] == 1)
        {
            $career += 23;
            if ($this->debug) echo "十宫主落命宫【+23】={$career}\n";
            if (!empty($this->base_data['planets'][$house10_protect_ancient]['phase'])
                && isset($this->base_data['planets'][$house10_protect_ancient]['phase'][$house10_protect_ancient . '-' . ASC]))
            {
                $group2_d++;
                $career += 15;
                if ($this->debug) echo "十宫主落命宫,若此时十宫主合上升【+15】={$career}\n";
            }
        }
//        20、	命主落十宫【+30】，若此时命主合中天【+18】
        if ($house1_protect['in_house_id'] == 10)
        {
            $career += 30;
            if ($this->debug) echo "命主落十宫【+30】={$career}\n";
            if (!empty($house1_protect['phase']) && isset($house1_protect['phase'][$house1_protect['id'] . '-' . MC]))
            {
                $group2_d++;
                $career += 18;
                if ($this->debug) echo "命主落十宫,若此时命主合中天【+18】={$career}\n";
            }
        }
        if ($house1_protect_ancient['in_house_id'] == 10)
        {
            $career += 30;
            if ($this->debug) echo "命主落十宫【+30】={$career}\n";
            if (!empty($house1_protect_ancient['phase']) && isset($house1_protect_ancient['phase'][$house1_protect_ancient['id'] . '-' . MC]))
            {
                $group2_d++;
                $career += 18;
                if ($this->debug) echo "命主落十宫,若此时命主合中天【+18】={$career}\n";
            }
        }
//        21、	命主与十宫主或十宫宫内星成相【+25】，若同时为接纳互容【+25】，相位同度【+15】，不是刑冲相位【+15】，入相位【+10】
        if (!empty($house1_protect['phase']))
        {
            $house1_pk_house10 = false;
            foreach ($house1_protect['phase'] as $h1p)
            {
                $p = $this->base_data['planets'][$h1p['id']];
                if ($h1p['id'] == $house10_protect || $h1p['id'] == $house10_protect_ancient || $p['in_house_id'] == 10)
                {
                    $house1_pk_house10 = true;
                    if ($this->is_accept_each_other($house1_protect['id'], $h1p['id']))
                    {
                        $career += 25;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,若同时为接纳互容【+25】={$career}\n";
                    }
                    if ($h1p['phase_orb'] < 1)
                    {
                        $career += 15;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,相位同度【+15】={$career}\n";
                    }
                    if (!in_array($h1p['phase_e'], [90, 180]))
                    {
                        $career += 15;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,不是刑冲相位【+15】={$career}\n";
                    }
                    if ($h1p['phase_change'] == '入相')
                    {
                        $career += 10;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,入相位【+10】={$career}\n";
                    }
                }

            }
            if ($house1_pk_house10 === true)
            {
                $group2_d++;
                $career += 25;
                if ($this->debug) echo "命主与十宫主或十宫宫内星成相【+25】={$career}\n";
            }
        }
        if ($house1_protect_ancient['id'] != $house1_protect['id'] && !empty($house1_protect_ancient['phase']))
        {
            $house1_pk_house10 = false;
            foreach ($house1_protect_ancient['phase'] as $h1p)
            {
                $p = $this->base_data['planets'][$h1p['id']];
                if ($h1p['id'] == $house10_protect || $h1p['id'] == $house10_protect_ancient || $p['in_house_id'] == 10)
                {
                    $house1_pk_house10 = true;
                    if ($this->is_accept_each_other($house1_protect_ancient['id'], $h1p['id']))
                    {
                        $career += 25;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,若同时为接纳互容【+25】={$career}\n";
                    }
                    if ($h1p['phase_orb'] < 1)
                    {
                        $career += 15;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,相位同度【+15】={$career}\n";
                    }
                    if (!in_array($h1p['phase_e'], [90, 180]))
                    {
                        $career += 15;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,不是刑冲相位【+15】={$career}\n";
                    }
                    if ($h1p['phase_change'] == '入相')
                    {
                        $career += 10;
                        if ($this->debug) echo "命主与十宫主或十宫宫内星成相,入相位【+10】={$career}\n";
                    }
                }

            }
            if ($house1_pk_house10 === true)
            {
                $group2_d++;
                $career += 25;
                if ($this->debug) echo "命主与十宫主或十宫宫内星成相【+25】={$career}\n";
            }
        }
//        22、	十宫主与命主无相位互容，【+25】   只计算本垣无相位互容
        $p10 = $this->base_data['planets'][$house10_protect];
        $p10_a = $this->base_data['planets'][$house10_protect_ancient];
        if ($p10['ancient']['or_walls_planet_id'] == $house1_protect_ancient['id']
            && !isset($p10['phase'][$house10_protect . '-' . $house1_protect_ancient['id']]))
        {
            $group2_d++;
            $career += 25;
            if ($this->debug) echo "十宫主与命主无相位互容【+25】={$career}\n";
        } elseif ($p10['ancient']['or_walls_planet_id'] == $house1_protect['id']
            && !isset($p10['phase'][$house10_protect . '-' . $house1_protect['id']]))
        {
            $group2_d++;
            $career += 25;
            if ($this->debug) echo "十宫主与命主无相位互容【+25】={$career}\n";
        } elseif ($p10_a['ancient']['or_walls_planet_id'] == $house1_protect['id']
            && !isset($p10_a['phase'][$house10_protect . '-' . $house1_protect['id']]))
        {
            $group2_d++;
            $career += 25;
            if ($this->debug) echo "十宫主与命主无相位互容【+25】={$career}\n";
        } elseif ($p10_a['ancient']['or_walls_planet_id'] == $house1_protect['id']
            && !isset($p10_a['phase'][$house10_protect . '-' . $house1_protect['id']]))
        {
            $group2_d++;
            $career += 25;
            if ($this->debug) echo "十宫主与命主无相位互容【+25】={$career}\n";
        }
//        23、	十宫内有火星，【+25】
        if ($mars['in_house_id'] == 10)
        {
            $group2_e++;
            $career += 25;
            if ($this->debug) echo "十宫内有火星【+25】={$career}\n";
        }
//        24、	令2为a组，3-10为b组，11-18为c组，19-22为d组，23为e组，若不止一组有加分，每多一组则额外【+25】
        $total_group2 = 0;
        if ($group2_a > 0) $total_group2++;
        if ($group2_b > 0) $total_group2++;
        if ($group2_c > 0) $total_group2++;
        if ($group2_d > 0) $total_group2++;
        if ($group2_e > 0) $total_group2++;
        if ($total_group2 > 1)
        {
            $career += (25 * ($total_group2 - 1));
            if ($this->debug) echo "令2为a组，3-10为b组，11-18为c组，19-22为d组，23为e组，若不止一组有加分，每多一组则额外【+25*{$total_group2}】={$career}\n";
        }

//        三、	日月
//        1、	太阳与木星成相【+40】，若同时有接纳互容【+35】，同度【+25】；
        if (!empty($sun['phase']) && isset($sun['phase']['0-5']))
        {
            $career += 40;
            if ($this->debug) echo "太阳与木星成相，则【+40】={$career}\n";
            if ($this->is_accept_each_other(0, 5))
            {
                $career += 35;
                if ($this->debug) echo "太阳与木星成相，若同时有接纳互容【+35】={$career}\n";
            }
            if ($sun['phase']['0-5']['phase_orb'] < 1)
            {
                $career += 25;
                if ($this->debug) echo "太阳与木星成相，同度【+25】={$career}\n";
            }
        }

//        2、	太阳与火星成相，是夜生盘或非刑冲合相【+20】，若同时有接纳互容【+15】，同度【+10】，同时有日金相位【+20】
        if (
            !empty($sun['phase']) && isset($sun['phase']['0-4'])
            && ($sun['in_house_id'] < 6 || !in_array($sun['phase']['0-4']['phase_e'], [0, 90, 180]))
        )
        {
            $career += 20;
            if ($this->debug) echo "太阳与火星成相，是夜生盘或非刑冲合相，则【+20】={$career}\n";
            if ($this->is_accept_each_other(0, 4))
            {
                $career += 15;
                if ($this->debug) echo "太阳与火星成相，是夜生盘或非刑冲合相，若同时有接纳互容【+15】={$career}\n";
            }
            if ($sun['phase']['0-4']['phase_orb'] < 1)
            {
                $career += 10;
                if ($this->debug) echo "太阳与火星成相，是夜生盘或非刑冲合相，同度【+10】={$career}\n";
            }
            if (isset($sun['phase']['0-3']))
            {
                $career += 20;
                if ($this->debug) echo "太阳与火星成相，是夜生盘或非刑冲合相，同时有日金相位【+20】={$career}\n";
            }
        }
//        3、	太阳与土星成相，是日生盘或非刑冲合相【+20】，若同时有接纳互容【+15】，同度【+10】，同时有日木相位【+20】
        if (
            !empty($sun['phase']) && isset($sun['phase']['0-6'])
            && ($sun['in_house_id'] > 6 || !in_array($sun['phase']['0-6']['phase_e'], [0, 90, 180]))
        )
        {
            $career += 20;
            if ($this->debug) echo "太阳与土星成相，是夜生盘或非刑冲合相，则【+20】={$career}\n";
            if ($this->is_accept_each_other(0, 6))
            {
                $career += 15;
                if ($this->debug) echo "太阳与土星成相，是夜生盘或非刑冲合相，若同时有接纳互容【+15】={$career}\n";
            }
            if ($sun['phase']['0-6']['phase_orb'] < 1)
            {
                $career += 10;
                if ($this->debug) echo "太阳与土星成相，是夜生盘或非刑冲合相，同度【+10】={$career}\n";
            }
            if (isset($sun['phase']['0-5']))
            {
                $career += 20;
                if ($this->debug) echo "太阳与土星成相，是夜生盘或非刑冲合相，同时有日木相位【+20】={$career}\n";
            }
        }
//        4、	太阳与金星成相【+20】，若同时有接纳互容【+15】，同度【+10】
        if (!empty($sun['phase']) && isset($sun['phase']['0-3']))
        {
            $career += 20;
            if ($this->debug) echo "太阳与金星成相，则【+20】={$career}\n";
            if ($this->is_accept_each_other(0, 3))
            {
                $career += 15;
                if ($this->debug) echo "太阳与金星成相，若同时有接纳互容【+15】={$career}\n";
            }
            if ($sun['phase']['0-3']['phase_orb'] < 1)
            {
                $career += 10;
                if ($this->debug) echo "太阳与金星成相，同度【+10】={$career}\n";
            }
        }
//        5、	月亮与木星成相【+30】，若同时有接纳互容【+25】，同度【+15】；
        if (!empty($moon['phase']) && isset($moon['phase']['1-5']))
        {
            $career += 30;
            if ($this->debug) echo "月亮与木星成相，则【+30】={$career}\n";
            if ($this->is_accept_each_other(1, 5))
            {
                $career += 25;
                if ($this->debug) echo "月亮与木星成相，若同时有接纳互容【+25】={$career}\n";
            }
            if ($moon['phase']['1-5']['phase_orb'] < 1)
            {
                $career += 15;
                if ($this->debug) echo "月亮与木星成相，同度【+15】={$career}\n";
            }
        }
//        6、	月亮与火星成相，是夜生盘或非刑冲合相【+30】，若同时有接纳互容【+20】，同度【+15】，同时有月金相位【+20】；
        if (
            !empty($moon['phase']) && isset($moon['phase']['1-4'])
            && ($sun['in_house_id'] < 6 || !in_array($moon['phase']['1-4']['phase_e'], [0, 90, 180]))
        )
        {
            $career += 30;
            if ($this->debug) echo "月亮与火星成相，是夜生盘或非刑冲合相，则【+30】={$career}\n";
            if ($this->is_accept_each_other(1, 4))
            {
                $career += 20;
                if ($this->debug) echo "月亮与火星成相，是夜生盘或非刑冲合相，若同时有接纳互容【+20】={$career}\n";
            }
            if ($moon['phase']['1-4']['phase_orb'] < 1)
            {
                $career += 15;
                if ($this->debug) echo "月亮与火星成相，是夜生盘或非刑冲合相，同度【+15】={$career}\n";
            }
            if (isset($moon['phase']['1-3']))
            {
                $career += 20;
                if ($this->debug) echo "月亮与火星成相，是夜生盘或非刑冲合相，同时有月金相位【+20】={$career}\n";
            }
        }
//        7、	月亮与金星成相【+30】，若同时有接纳互容【+25】，同度【+20】
        if (!empty($moon['phase']) && isset($moon['phase']['1-3']))
        {
            $career += 30;
            if ($this->debug) echo "月亮与金星成相，则【+30】={$career}\n";
            if ($this->is_accept_each_other(1, 3))
            {
                $career += 25;
                if ($this->debug) echo "月亮与金星成相，若同时有接纳互容【+25】={$career}\n";
            }
            if ($moon['phase']['1-3']['phase_orb'] < 1)
            {
                $career += 20;
                if ($this->debug) echo "月亮与金星成相，同度【+20】={$career}\n";
            }
        }
//        四、	气象
//        1、	若升日月金水火四象齐全，则【*1.2】
        $four_class = [0, 0, 0, 0];
        $four_class[$sun['in_sign_id'] % 4]++;
        $four_class[$moon['in_sign_id'] % 4]++;
        $four_class[$merc['in_sign_id'] % 4]++;
        $four_class[$venu['in_sign_id'] % 4]++;
        $four_class[$mars['in_sign_id'] % 4]++;
        $four_class[$this->base_data['planets'][ASC]['in_sign_id'] % 4]++;
        if ($four_class[0] > 0 && $four_class[1] > 0 && $four_class[2] > 0 && $four_class[3] > 0)
        {
            $career *= 1.2;
            if ($this->debug) echo "若升日月金水火四象齐全，则【*1.2】={$career}\n";
        }
//        2、	若某颗星独占半球，且不在12宫，【*1.1】
        $in_earth = [[], [], [], []];// 东南西北半球
        for ($i = 0; $i < 10; $i++)
        {
            $p = $this->base_data['planets'][$i];
            if ($p['in_house_id'] > 3 && $p['in_house_id'] < 10)
            {
                $in_earth[0][] = $p['id'];
            }
            if ($p['in_house_id'] < 7)
            {
                $in_earth[1][] = $p['id'];
            }
            if ($p['in_house_id'] > 9 || $p['in_house_id'] < 4)
            {
                $in_earth[2][] = $p['id'];
            }
            if ($p['in_house_id'] > 6)
            {
                $in_earth[3][] = $p['id'];
            }
        }
        if (count($in_earth[0]) == 1 && $this->base_data['planets'][$in_earth[0][0]]['in_house_id'] != 12)
        {
            $career *= 1.1;
            if ($this->debug) echo "若某颗星独占半球，且不在12宫，【*1.1】={$career}\n";
        }
        if (count($in_earth[1]) == 1 && $this->base_data['planets'][$in_earth[1][0]]['in_house_id'] != 12)
        {
            $career *= 1.1;
            if ($this->debug) echo "若某颗星独占半球，且不在12宫，【*1.1】={$career}\n";
        }
        if (count($in_earth[2]) == 1 && $this->base_data['planets'][$in_earth[2][0]]['in_house_id'] != 12)
        {
            $career *= 1.1;
            if ($this->debug) echo "若某颗星独占半球，且不在12宫，【*1.1】={$career}\n";
        }
        if (count($in_earth[3]) == 1 && $this->base_data['planets'][$in_earth[3][0]]['in_house_id'] != 12)
        {
            $career *= 1.1;
            if ($this->debug) echo "若某颗星独占半球，且不在12宫，【*1.1】={$career}\n";
        }
//        3、	若十宫主不落10宫，所落宫位5号元素影响>0.4，同时9号或2号或7号元素影响>0.4，【*1.2】
        if ($p10['in_house_id'] != 10 && !isset($p10['phase'][$p10['id'] . '-' . MC]))
        {
            $hower = new Housepower($this->base_data);
            $house_data = $hower->house_influence($this->base_data['houses'][$p10['in_house_id']]);
            if ($house_data[5] > 0.4 && ($house_data[9] > 0.4 || $house_data[2] > 0.4 || $house_data[7] > 0.4))
            {
                $career *= 1.2;
                if ($this->debug) echo "若十宫主不落10宫，所落宫位5号元素影响>0.4，同时9号或2号或7号元素影响>0.4，【*1.2】={$career}\n";
            }
        }
//        4、	全天最高星体为日、月或命主星，且位于9、10/11宫，【*1.1】
        $top_planet = null;// 全天最高星体
        for ($i = 0; $i < 10; $i++)
        {
            if ($this->is_zhigao($i))
            {
                $top_planet = $i;
            }
        }
        if (in_array($top_planet, [0, 1, $house1_protect['id'], $house1_protect_ancient['id']]))
        {
            if (in_array($this->base_data['planets'][$top_planet]['in_house_id'], [9, 10, 11]))
            {
                $career *= 1.1;
                if ($this->debug) echo "全天最高星体为日、月或命主星，且位于9、10/11宫，【*1.1】={$career}\n";
            }
        }
//        五、	删减
//        1、	若月亮与10宫宫内星或十宫主成四分相，-80；
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $m_phase)
            {
                if ($m_phase['id'] < 10 && $m_phase['phase_e'] == 90)
                {
                    if (
                        $this->base_data['planets'][$m_phase['id']]['in_house_id'] == 10
                        || $m_phase['id'] == $house10_protect
                        || $m_phase['id'] == $house10_protect_ancient
                    )
                    {
                        $career -= 80;
                        if ($this->debug) echo "若月亮与10宫宫内星或十宫主成四分相-80={$career}\n";
                    }
                }
            }
        }
//        2、	若太阳或月亮在12宫被刑冲，-80；
        if ($sun['in_house_id'] == 12)
        {
            if (!empty($sun['phase']))
            {
                foreach ($sun['phase'] as $s_phase)
                {
                    if ($s_phase['id'] < 10 && in_array($s_phase['phase_e'], [90, 180]))
                    {
                        $career -= 80;
                        if ($this->debug) echo "若太阳在12宫被刑冲-80={$career}\n";
                    }
                }
            }
        }
        if ($moon['in_house_id'] == 12)
        {
            if (!empty($moon['phase']))
            {
                foreach ($moon['phase'] as $m_phase)
                {
                    if ($m_phase['id'] < 10 && in_array($m_phase['phase_e'], [90, 180]))
                    {
                        $career -= 80;
                        if ($this->debug) echo "若月亮在12宫被刑冲-80={$career}\n";
                    }
                }
            }
        }
//        3、	若太阳或月亮在6宫被刑冲，-60；
        if ($sun['in_house_id'] == 6)
        {
            if (!empty($sun['phase']))
            {
                foreach ($sun['phase'] as $s_phase)
                {
                    if ($s_phase['id'] < 10 && in_array($s_phase['phase_e'], [90, 180]))
                    {
                        $career -= 60;
                        if ($this->debug) echo "若太阳在6宫被刑冲-60={$career}\n";
                    }
                }
            }
        }
        if ($moon['in_house_id'] == 6)
        {
            if (!empty($moon['phase']))
            {
                foreach ($moon['phase'] as $m_phase)
                {
                    if ($m_phase['id'] < 10 && in_array($m_phase['phase_e'], [90, 180]))
                    {
                        $career -= 60;
                        if ($this->debug) echo "若月亮在6宫被刑冲-60={$career}\n";
                    }
                }
            }
        }
//        4、	若10宫主落12宫，-30；
        if ($this->base_data['planets'][$house10_protect]['in_house_id'] == 12)
        {
            $career -= 30;
            if ($this->debug) echo "若10宫主落12宫-30={$career}\n";
        }
//        5、	若全天最高的星体位于12宫，-80
        if ($this->base_data['planets'][$top_planet]['in_house_id'] == 12)
        {
            $career -= 80;
            if ($this->debug) echo "若全天最高的星体位于12宫-80={$career}\n";
        }
        // 补丁 - -
        // 1、若10宫主入庙或擢升且与命主合相，同时日木是太阳的唯一相位且日木存在本垣或擢升接纳【+200】，若为日生盘【+50】
        if (
            (($p10['ancient']['walls'] == 1 || $p10['ancient']['promote'] == 1)
                || (($p10_a['ancient']['walls'] == 1 || $p10_a['ancient']['promote'] == 1)))
            && (isset($p10['phase'][$p10['id'] . '-' . $house1_protect_ancient['id']])
                && $p10['phase'][$p10['id'] . '-' . $house1_protect_ancient['id']]['phase_e'] == 0)
        )
        {
            $sss_phase_num = 0;
            if (!empty($sun['phase']))
            {
                foreach ($sun['phase'] as $sp)
                {
                    if ($sp['id'] > 9) continue;
                    $sss_phase_num++;
                }
                // 日木唯一相位
                if ($sss_phase_num == 1 && isset($sun['phase']['0-5']))
                {
                    if (
                        $sun['ancient']['or_walls_planet_id'] == 5 || $sun['ancient']['or_promote_planet_id'] == 5
                        || $jupi['ancient']['or_walls_planet_id'] == 5 || $jupi['ancient']['or_promote_planet_id'] == 5
                    )
                    {
                        $career += 200;
                        if ($this->debug) echo "若10宫主入庙或擢升且与命主合相，同时日木是太阳的唯一相位且日木存在本垣或擢升接纳【+200】={$career}\n";
                        if ($sun['in_house_id'] > 6)
                        {
                            $career += 50;
                            if ($this->debug) echo "若10宫主入庙或擢升且与命主合相，同时日木是太阳的唯一相位且日木存在本垣或擢升接纳,若为日生盘【+50】={$career}\n";
                        }
                    }
                }
            }
        }
        $career = round($career * 0.8);

        return $career;
    }

    /**
     * 获取财富分数
     * @return int
     */
    protected function getTheMoney()
    {
        $house2 = $this->base_data['houses'][2];
        $house5 = $this->base_data['houses'][5];
        $house8 = $this->base_data['houses'][8];
        $sun = $this->base_data['planets'][0];
        $moon = $this->base_data['planets'][1];
        $merc = $this->base_data['planets'][2];
        $venu = $this->base_data['planets'][3];
        $mars = $this->base_data['planets'][4];
        $jupi = $this->base_data['planets'][5];
        $satu = $this->base_data['planets'][6];
        $nept = $this->base_data['planets'][8];
        $plut = $this->base_data['planets'][9];
//        一、  基数
//        【=事业指数/2】
        $money = $this->career / 2;
        if ($this->debug) echo "财富基数=事业分数/2=$money\n";
//        二、  二宫
//        1、    满足宫主星黄道力量判定【+45】PlanetPower()
        $h2_pp = $this->PlanetPower($house2['protect_id']);
        $is_h2_pp_status = false;
        if (
            $h2_pp['walls'] == 1 || $h2_pp['promote'] == 1
            || !empty($h2_pp['walls_accept']) || !empty($h2_pp['promote_accept'])
            || !empty($h2_pp['accept_each_other'])
        )
        {
            $is_h2_pp_status = true;
        }
        if ($house2['protect_id'] != $house2['protect_ancient_id'])
        {
            $h2_a_pp = $this->PlanetPower($house2['protect_ancient_id']);
            if (
                $h2_a_pp['walls'] == 1 || $h2_a_pp['promote'] == 1
                || !empty($h2_a_pp['walls_accept']) || !empty($h2_a_pp['promote_accept'])
                || !empty($h2_a_pp['accept_each_other'])
            )
            {
                $is_h2_pp_status = true;
            }
        }
        if ($is_h2_pp_status == true)
        {
            $money += 45;
            if ($this->debug) echo "满足宫主星黄道力量判定【+45】=$money\n";
        }
//        2、    宫头在狮子座、金牛座、天蝎座【+25】白羊座巨蟹座射手座双鱼座【+15】
        if (in_array($house2['in_sign_id'], [2, 5, 8]))
        {
            $money += 25;
            if ($this->debug) echo " 宫头在狮子座、金牛座、天蝎座【+25】=$money\n";
        } elseif (in_array($house2['in_sign_id'], [1, 4, 9, 12]))
        {
            $money += 15;
            if ($this->debug) echo " 宫头在白羊座、巨蟹座、射手座、双鱼座【+15】=$money\n";
        }
//        3、    宫主星落在狮子座、金牛座、天蝎座【+25】，白羊座、巨蟹座、射手座【+15】
        if (in_array($house2['protect_id'], [2, 5, 8]))
        {
            $money += 25;
            if ($this->debug) echo " 宫主星在狮子座、金牛座、天蝎座【+25】=$money\n";
        } elseif (in_array($house2['protect_id'], [1, 4, 9]))
        {
            $money += 15;
            if ($this->debug) echo " 宫主星在白羊座、巨蟹座、射手座【+15】=$money\n";
        }
        if ($house2['protect_id'] != $house2['protect_ancient_id'])
        {
            if (in_array($house2['protect_ancient_id'], [2, 5, 8]))
            {
                $money += 25;
                if ($this->debug) echo " 宫主星在狮子座、金牛座、天蝎座【+25】=$money\n";
            } elseif (in_array($house2['protect_ancient_id'], [1, 4, 9]))
            {
                $money += 15;
                if ($this->debug) echo " 宫主星在白羊座、巨蟹座、射手座【+15】=$money\n";
            }
        }
//        4、    月亮落宫【+40-受伤度/4】
        if ($moon['in_house_id'] == 2)
        {
            $money += (40 - $this->planet_power[1]['burn'] / 4);
            if ($this->debug) echo " 月亮落宫【+40-受伤度{$this->planet_power[1]['burn']}/4】=$money\n";
        }
//        5、    火星落宫且不与海王合刑冲【+30】，若此时满足黄道力量判定【+30】
        if ($mars['in_house_id'] == 2 && (!empty($mars['phase']) || (isset($mars['phase']['4-8'])) && !in_array($mars['phase']['4-8']['phase_e'], [0, 90, 180])))
        {
            $money += 30;
            if ($this->debug) echo "火星落宫且不与海王合刑冲【+30】=$money\n";
            // 火星黄道力量判定
            $mars_pp = $this->PlanetPower(4);
            if (
                $mars_pp['walls'] == 1 || $mars_pp['promote'] == 1
                || !empty($mars_pp['walls_accept']) || !empty($mars_pp['promote_accept'])
                || !empty($mars_pp['accept_each_other'])
            )
            {
                $money += 30;
                if ($this->debug) echo "火星落宫且不与海王合刑冲，若此时满足黄道力量判定【+45】=$money\n";
            }
        }
//        6、    木星落宫【+40】，若在狮子金牛天蝎巨蟹射手【+40】
        if ($jupi['in_house_id'] == 2)
        {
            $money += 40;
            if ($this->debug) echo "木星落宫【+40】=$money\n";
            if (in_array($jupi['in_sign_id'], [2, 5, 8, 9]))
            {
                $money += 40;
                if ($this->debug) echo "木星落2宫，若在狮子金牛天蝎巨蟹射手【+40】=$money\n";
            }
        }
//        7、    金星落宫【+30】，若在狮子\金牛\天秤\天蝎\巨蟹\射手【+35】
        if ($venu['in_house_id'] == 2)
        {
            $money += 40;
            if ($this->debug) echo "金星落宫【+40】=$money\n";
            if (in_array($venu['in_sign_id'], [2, 4, 5, 7, 8, 9]))
            {
                $money += 40;
                if ($this->debug) echo "金星落宫，若在狮子金牛天蝎巨蟹射手【+40】=$money\n";
            }
        }
//        8、    水星落宫【+10】，若满足黄道力量判定【+30】
        if ($merc['in_house_id'] == 2)
        {
            $money += 10;
            if ($this->debug) echo "水星落宫【+10】=$money\n";
            // 水星黄道力量判定
            $merc_pp = $this->PlanetPower(2);
            if (
                $merc_pp['walls'] == 1 || $merc_pp['promote'] == 1
                || !empty($merc_pp['walls_accept']) || !empty($merc_pp['promote_accept'])
                || !empty($merc_pp['accept_each_other'])
            )
            {
                $money += 30;
                if ($this->debug) echo "水星落宫，若此时满足黄道力量判定【+30】=$money\n";
            }
        }
//        9、    若8宫或5宫宫主星落2宫且无“不带接纳互容的刑冲”【+50】
        $house5_protect_planet = $this->base_data['planets'][$house5['protect_ancient_id']];
        $house8_protect_planet = $this->base_data['planets'][$house8['protect_ancient_id']];
        if ($house5_protect_planet['in_house_id'] == 2)
        {
            $status_5 = true;
            if (!empty($house5_protect_planet['phase']))
            {
                foreach ($house5_protect_planet['phase'] as $h5pp)
                {
                    if (in_array($h5pp['phase_e'], [90, 180]))
                    {
                        if (!$this->is_accept_each_other($house5_protect_planet['id'], $h5pp['id']))
                        {
                            $status_5 = false;
                        }
                    }
                }
            }
        } else
        {
            $status_5 = false;
        }
        if ($house8_protect_planet['in_house_id'] == 2)
        {
            $status_8 = true;
            if (!empty($house8_protect_planet['phase']))
            {
                foreach ($house8_protect_planet['phase'] as $h8pp)
                {
                    if (in_array($h8pp['phase_e'], [90, 180]))
                    {
                        if (!$this->is_accept_each_other($house8_protect_planet['id'], $h8pp['id']))
                        {
                            $status_8 = false;
                        }
                    }
                }
            }
        } else
        {
            $status_8 = false;
        }

        if ($status_5 === true || $status_8 === true)
        {
            $money += 50;
            if ($this->debug) echo "若8宫或5宫宫主星落2宫且无“不带接纳互容的刑冲”【+50】=$money\n";
        }
//        10、  若2宫主落8宫或5宫且无“不带接纳互容的刑冲”，【+50】
        $house2_protect_planet = $this->base_data['planets'][$house2['protect_ancient_id']];
        if ($house2_protect_planet['in_house_id'] == 8 || $house2_protect_planet['in_house_id'] == 5)
        {
            $status_2 = true;
            if (!empty($house2_protect_planet['phase']))
            {
                foreach ($house2_protect_planet['phase'] as $h2pp)
                {
                    if (in_array($h2pp['phase_e'], [90, 180]))
                    {
                        if (!$this->is_accept_each_other($house2_protect_planet['id'], $h2pp['id']))
                        {
                            $status_2 = false;
                        }
                    }
                }
            }
            if ($status_2 === true)
            {
                $money += 50;
                if ($this->debug) echo "若2宫主落8宫或5宫且无“不带接纳互容的刑冲”，【+50】=$money\n";
            }
        }
//        三、8宫
//        对8宫应用2宫的1-8条检测，得分累计。
//        1、    满足宫主星黄道力量判定【+45】PlanetPower()
        $h8_pp = $this->PlanetPower($house8['protect_id']);
        $is_h8_pp_status = false;
        if (
            $h8_pp['walls'] == 1 || $h8_pp['promote'] == 1
            || !empty($h8_pp['walls_accept']) || !empty($h8_pp['promote_accept'])
            || !empty($h8_pp['accept_each_other'])
        )
        {
            $is_h8_pp_status = true;
        }
        if ($house8['protect_id'] != $house8['protect_ancient_id'])
        {
            $h8_a_pp = $this->PlanetPower($house8['protect_ancient_id']);
            if (
                $h8_a_pp['walls'] == 1 || $h8_a_pp['promote'] == 1
                || !empty($h8_a_pp['walls_accept']) || !empty($h8_a_pp['promote_accept'])
                || !empty($h8_a_pp['accept_each_other'])
            )
            {
                $is_h8_pp_status = true;
            }
        }
        if ($is_h8_pp_status == true)
        {
            $money += 45;
            if ($this->debug) echo "满足宫主星黄道力量判定【+45】=$money\n";
        }
//        2、    宫头在狮子座、金牛座、天蝎座【+25】白羊座巨蟹座射手座双鱼座【+15】
        if (in_array($house8['in_sign_id'], [2, 5, 8]))
        {
            $money += 25;
            if ($this->debug) echo " 宫头在狮子座、金牛座、天蝎座【+25】=$money\n";
        } elseif (in_array($house8['in_sign_id'], [1, 4, 9, 12]))
        {
            $money += 15;
            if ($this->debug) echo " 宫头在白羊座、巨蟹座、射手座、双鱼座【+15】=$money\n";
        }
//        3、    宫主星落在狮子座、金牛座、天蝎座【+25】，白羊座、巨蟹座、射手座【+15】
        if (in_array($house8['protect_id'], [2, 5, 8]))
        {
            $money += 25;
            if ($this->debug) echo " 宫主星在狮子座、金牛座、天蝎座【+25】=$money\n";
        } elseif (in_array($house8['protect_id'], [1, 4, 9]))
        {
            $money += 15;
            if ($this->debug) echo " 宫主星在白羊座、巨蟹座、射手座【+15】=$money\n";
        }
        if ($house8['protect_id'] != $house8['protect_ancient_id'])
        {
            if (in_array($house8['protect_ancient_id'], [2, 5, 8]))
            {
                $money += 25;
                if ($this->debug) echo " 宫主星在狮子座、金牛座、天蝎座【+25】=$money\n";
            } elseif (in_array($house8['protect_ancient_id'], [1, 4, 9]))
            {
                $money += 15;
                if ($this->debug) echo " 宫主星在白羊座、巨蟹座、射手座【+15】=$money\n";
            }
        }
//        4、    月亮落宫【+40-受伤度/4】
        if ($moon['in_house_id'] == 8)
        {
            $money += (40 - $this->planet_power[1]['burn'] / 4);
            if ($this->debug) echo " 月亮落宫【+40-受伤度{$this->planet_power[1]['burn']}/4】=$money\n";
        }
//        5、    火星落宫且不与海王合刑冲【+30】，若此时满足黄道力量判定【+30】
        if ($mars['in_house_id'] == 8 && (!empty($mars['phase']) || (isset($mars['phase']['4-8'])) && !in_array($mars['phase']['4-8']['phase_e'], [0, 90, 180])))
        {
            $money += 30;
            if ($this->debug) echo "火星落宫且不与海王合刑冲【+30】=$money\n";
            // 火星黄道力量判定
            $mars_pp = $this->PlanetPower(4);
            if (
                $mars_pp['walls'] == 1 || $mars_pp['promote'] == 1
                || !empty($mars_pp['walls_accept']) || !empty($mars_pp['promote_accept'])
                || !empty($mars_pp['accept_each_other'])
            )
            {
                $money += 30;
                if ($this->debug) echo "火星落宫且不与海王合刑冲，若此时满足黄道力量判定【+45】=$money\n";
            }
        }
//        6、    木星落宫【+40】，若在狮子金牛天蝎巨蟹射手【+40】
        if ($jupi['in_house_id'] == 8)
        {
            $money += 40;
            if ($this->debug) echo "木星落宫【+40】=$money\n";
            if (in_array($jupi['in_sign_id'], [2, 5, 8, 9]))
            {
                $money += 40;
                if ($this->debug) echo "木星落2宫，若在狮子金牛天蝎巨蟹射手【+40】=$money\n";
            }
        }
//        7、    金星落宫【+30】，若在狮子\金牛\天秤\天蝎\巨蟹\射手【+35】
        if ($venu['in_house_id'] == 8)
        {
            $money += 40;
            if ($this->debug) echo "金星落宫【+40】=$money\n";
            if (in_array($venu['in_sign_id'], [2, 4, 5, 7, 8, 9]))
            {
                $money += 40;
                if ($this->debug) echo "金星落宫，若在狮子金牛天蝎巨蟹射手【+40】=$money\n";
            }
        }
//        8、    水星落宫【+10】，若满足黄道力量判定【+30】
        if ($merc['in_house_id'] == 8)
        {
            $money += 10;
            if ($this->debug) echo "水星落宫【+10】=$money\n";
            // 水星黄道力量判定
            $merc_pp = $this->PlanetPower(2);
            if (
                $merc_pp['walls'] == 1 || $merc_pp['promote'] == 1
                || !empty($merc_pp['walls_accept']) || !empty($merc_pp['promote_accept'])
                || !empty($merc_pp['accept_each_other'])
            )
            {
                $money += 30;
                if ($this->debug) echo "水星落宫，若此时满足黄道力量判定【+30】=$money\n";
            }
        }

//        一、  考察金星状态
        $score = 1;
//        1、    满足黄道力量判定，【1.1】
        // 金星黄道力量判定
        $venu_pp = $this->PlanetPower(3);
        if (
            $venu_pp['walls'] == 1 || $venu_pp['promote'] == 1
            || !empty($venu_pp['walls_accept']) || !empty($venu_pp['promote_accept'])
            || !empty($venu_pp['accept_each_other'])
        )
        {
            $score *= 1.1;
            if ($this->debug) echo "金星满足黄道力量判定【*1.1】=$score\n";
        }
//        2、    与木星成相【1.1】
        if (!empty($venu['phase']) && isset($venu['phase']['3-5']))
        {
            $score *= 1.1;
            if ($this->debug) echo "与木星成相【*1.1】=$score\n";
        }
//        3、    与火星拱六分【1.05】
        if (!empty($venu['phase']) && isset($venu['phase']['3-4']) && in_array($venu['phase']['3-4']['phase_e'], [60, 120]))
        {
            $score *= 1.05;
            if ($this->debug) echo "与火星拱六分【*1.05】=$score\n";
        }
//        4、    失势落陷且有刑冲相位【0.85】
        $venu_have_90_180 = false;
        if ($venu['ancient']['walls'] == 2 || $venu['ancient']['promote'] == 2)
        {
            if (!empty($venu['phase']))
            {
                foreach ($venu['phase'] as $vp)
                {
                    if (in_array($vp['phase_e'], [90, 180])) $venu_have_90_180 = true;
                }
            }
            if ($venu_have_90_180 === true)
            {
                $score *= 0.85;
                if ($this->debug) echo "与火星拱六分【*0.85】=$score\n";
            }
        }
//        5、    被火星合刑冲【0.9】
        if (!empty($venu['phase']) && isset($venu['phase']['3-4']) && in_array($venu['phase']['3-4']['phase_e'], [0, 90, 180]))
        {
            $score *= 0.9;
            if ($this->debug) echo "被火星合刑冲【*0.9】=$score\n";
        }
//        6、    被土星合刑冲【0.9】
        if (!empty($venu['phase']) && isset($venu['phase']['3-6']) && in_array($venu['phase']['3-6']['phase_e'], [0, 90, 180]))
        {
            $score *= 0.9;
            if ($this->debug) echo "被土星合刑冲【*0.9】=$score\n";
        }
//        7、    落12宫且不合上升【0.9】
        if ($venu['in_house_id'] == 12 && !isset($venu['phase']['3-' . ASC]))
        {
            $score *= 0.9;
            if ($this->debug) echo "落12宫且不合上升【*0.9】=$score\n";
        }
//        8、    合上升或中天【1.2】
        if (!empty($venu['phase']) && (isset($venu['phase']['3-' . ASC]) || isset($venu['phase']['3-' . ASC])))
        {
            $score *= 1.2;
            if ($this->debug) echo "合上升或中天【*1.2】=$score\n";
        }
//        9、    落1或10宫【1.05】
        if ($venu['in_house_id'] == 1 || $venu['in_house_id'] == 10)
        {
            $score *= 1.05;
            if ($this->debug) echo "落1或10宫【*1.05】=$score\n";
        }
//             依次考察以上各项并令所得相乘，作为财富加权系数
//        五、前三项所得相加，再乘以财富加权系数

        $money *= $score;
        $money = round($money);

        return $money;
    }

    /**
     * 获取家庭分数
     */
    protected function getTheHome()
    {

        $sun = $this->base_data['planets'][0];
        $moon = $this->base_data['planets'][1];
        $merc = $this->base_data['planets'][2];
        $venu = $this->base_data['planets'][3];
        $mars = $this->base_data['planets'][4];
        $jupi = $this->base_data['planets'][5];
        $satu = $this->base_data['planets'][6];
        $nept = $this->base_data['planets'][8];
        $plut = $this->base_data['planets'][9];
        $house4_planet = $this->base_data['planets'][$this->base_data['houses'][4]['protect_ancient_id']];
//        情感呵护，物质给养，父母和谐，灾病离乱，成长帮助
//        1、    基础值=月亮的力量-月亮的损伤+（金星的力量-金星的损伤）/2+（太阳的力量-太阳的损伤）/2+（4宫的成就-4宫的挑战）
        $home = $this->planet_power[1]['stabilize'] - $this->planet_power[1]['burn']
            + ($this->planet_power[3]['stabilize'] - $this->planet_power[3]['burn']) / 2
            + ($this->planet_power[0]['stabilize'] - $this->planet_power[0]['burn']) / 2
            + ($this->house_score[3]['lucky'] - $this->house_score[3]['burn']);
//        if($this->debug) echo "基础值=月亮的力量{$this->planet_power['power'][1]}-月亮的损伤{$this->planet_power[1]['burn']}
//        +（金星的力量{$this->planet_power['power'][3]}-金星的损伤{$this->planet_power[3]['burn']}）/2
//        +（太阳的力量{$this->planet_power['power'][0]}-太阳的损伤{$this->planet_power[0]['burn']}）/2
//        +（4宫的成就{$this->house_score[3]['lucky']}-4宫的挑战{$this->house_score[3]['burn']}）={$home}\n";
        if ($this->debug) echo "家庭基础知识$home";
//        2、    若月亮落巨蟹或金牛【+80】
        if (in_array($moon['in_sign_id'], [2, 4]))
        {
            $home += 80;
            if ($this->debug) echo "若月亮落巨蟹或金牛【+80】\n";
        }
//        3、    若月亮落狮子或射手【+40】
        if (in_array($moon['in_sign_id'], [5, 9]))
        {
            $home += 40;
            if ($this->debug) echo "若月亮落狮子或射手【+40】\n";
        }
//        4、    若月亮落处女、双子、天秤【-30】
        if (in_array($moon['in_sign_id'], [3, 6, 7]))
        {
            $home -= 30;
            if ($this->debug) echo "若月亮落处女、双子、天秤【-30】\n";
        }
//        5、    若月亮落12宫【-50】，或落6宫【-25】，或落8宫【-35】；若此时月亮与土星刑冲合【-80】
        if ($moon['in_house_id'] == 12)
        {
            $home -= 50;
            if ($this->debug) echo " 若月亮落12宫【-50】\n";
            if (isset($moon['phase']['1-6']) && in_array($moon['phase']['1-6']['phase_e'], [0, 90, 180]))
            {
                $home -= 80;
                if ($this->debug) echo " 若月亮落12宫,若此时月亮与土星刑冲合【-80】\n";
            }
        }
        if ($moon['in_house_id'] == 6)
        {
            $home -= 25;
            if ($this->debug) echo " 若月亮落6宫【-25】\n";
            if (isset($moon['phase']['1-6']) && in_array($moon['phase']['1-6']['phase_e'], [0, 90, 180]))
            {
                $home -= 80;
                if ($this->debug) echo " 若月亮落6宫,若此时月亮与土星刑冲合【-80】\n";
            }
        }
        if ($moon['in_house_id'] == 8)
        {
            $home -= 35;
            if ($this->debug) echo " 若月亮落8宫【-35】\n";
            if (isset($moon['phase']['1-6']) && in_array($moon['phase']['1-6']['phase_e'], [0, 90, 180]))
            {
                $home -= 80;
                if ($this->debug) echo " 若月亮落8宫,若此时月亮与土星刑冲合【-80】\n";
            }
        }
//        6、    若月亮落在1宫【+50】，或4/7/10宫+【30】；若此时月亮刑冲土星【-80】
        if ($moon['in_house_id'] == 1)
        {
            $home += 50;
            if ($this->debug) echo " 若月亮落1宫【+50】\n";
            if (isset($moon['phase']['1-6']) && in_array($moon['phase']['1-6']['phase_e'], [90, 180]))
            {
                $home -= 80;
                if ($this->debug) echo " 若月亮落8宫,若此时月亮与土星刑冲合【-80】\n";
            }
        }
        if (in_array($moon['in_house_id'], [4, 7, 10]))
        {
            $home += 30;
            if ($this->debug) echo " 若月亮落在4/7/10宫【+30】\n";
            if (isset($moon['phase']['1-6']) && in_array($moon['phase']['1-6']['phase_e'], [90, 180]))
            {
                $home -= 80;
                if ($this->debug) echo " 若月亮落8宫,若此时月亮与土星刑冲合【-80】\n";
            }
        }
//        7、    若日月刑冲合【-50】，若此时日月之一在8或12宫【-100】
        if (isset($moon['phase']['1-0']) && in_array($moon['phase']['1-0']['phase_e'], [0, 90, 180]))
        {
            $home -= 50;
            if ($this->debug) echo " 若日月刑冲合【-50】\n";
            if (in_array($sun['in_house_id'], [8, 12]) || in_array($moon['in_house_id'], [8, 12]))
            {
                $home -= 100;
                if ($this->debug) echo " 若日月刑冲合，若此时日月之一在8或12宫【-100】\n";
            }
        }
//        8、    若月亮与金星成非刑相【+60】
        if (isset($moon['phase']['1-3']) && $moon['phase']['1-3']['phase_e'] != 90)
        {
            $home += 60;
            if ($this->debug) echo "若月亮与金星成非刑相【+60】\n";
        }
//        9、    若月亮与木星成相【+50】
        if (isset($moon['phase']['1-5']))
        {
            $home += 50;
            if ($this->debug) echo "若月亮与木星成相【+50】\n";
        }
//        10、  若日月与X星同时成相（x星可为多颗，重复加减）若x为火星【-60】，x为土星【-60】，x为天王星【-70】，x为海王星【-65】，x为冥王星【-50】
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $mp)
            {
                $pid = $mp['id'];
                if (isset($sun['phase']['0-' . $pid]))
                {
                    if ($pid == 4)
                    {
                        $home -= 60;
                        if ($this->debug) echo "若日月与火星同时成相【-60】\n";
                    } elseif ($pid == 6)
                    {
                        $home -= 60;
                        if ($this->debug) echo "若日月与土星同时成相【-60】\n";
                    } elseif ($pid == 7)
                    {
                        $home -= 70;
                        if ($this->debug) echo "若日月与天王星同时成相【-70】\n";
                    } elseif ($pid == 8)
                    {
                        $home -= 65;
                        if ($this->debug) echo "若日月与海王星同时成相【-65】\n";
                    } elseif ($pid == 9)
                    {
                        $home -= 50;
                        if ($this->debug) echo "若日月与冥王星同时成相【-50】\n";
                    }
                }
            }
        }
//        11、  火星落4宫【-40】，若此时月火刑【-80】
        if ($mars['in_house_id'] == 4)
        {
            $home -= 40;
            if ($this->debug) echo "火星落4宫【-40】\n";
            if (isset($moon['phase']['1-4']) && $moon['phase']['1-4']['phase_e'] == 90)
            {
                $home -= 80;
                if ($this->debug) echo "火星落4宫，若此时月火刑【-80】\n";
            }
        }
//        12、  土星落4宫【-60】，若此时月土刑【-120】
        if ($satu['in_house_id'] == 4)
        {
            $home -= 60;
            if ($this->debug) echo "土星落4宫【-60】\n";
            if (isset($moon['phase']['1-6']) && $moon['phase']['1-6']['phase_e'] == 90)
            {
                $home -= 120;
                if ($this->debug) echo "土星落4宫，若此时月土刑【-120】\n";
            }
        }
//        13、  若月亮落在双鱼座，【*1.15】
        if ($moon['in_sign_id'] == 12)
        {
            $home *= 1.15;
            if ($this->debug) echo "若月亮落在双鱼座，【*1.15】\n";
        }

//        附加：
        $f1 = $f2 = false;
//        1、    若月亮参与T三角，或月亮同时有四分相和对分相，则【-100】；
        $bad_moon = false;
        if (!empty($this->base_data['structure']['t_square']))
        {
            foreach ($this->base_data['structure']['t_square'] as $str_stru)
            {
                if ($str_stru[0]['id'] == 1 || $str_stru[1]['id'] == 1 || $str_stru[2]['id'] == 1)
                {
                    $bad_moon = true;
                }
            }
        }
        $mp_90 = false;
        $mp_180 = false;
        if (!empty($moon['phase']))
        {
            foreach ($moon['phase'] as $mp)
            {
                if ($mp['phase_e'] == 90)
                {
                    $mp_90 = true;
                } elseif ($mp['phase_e'] == 180)
                {
                    $mp_180 = true;
                }
            }
        }
        if ($bad_moon === true || ($mp_90 === true && $mp_180 === true))
        {
            $f1 = true;
            $home -= 100;
            if ($this->debug) echo "若月亮参与T三角，或月亮同时有四分相和对分相，则【-100】\n";
        }

//        2、    四宫主失势落陷，且与火土天海冥成相，每多一个，【-30】
        if ($house4_planet['ancient']['walls'] == 2 || $house4_planet['ancient']['promote'] == 2)
        {
            if (!empty($house4_planet['phase']))
            {
                foreach ($house4_planet['phase'] as $hp4)
                {
                    if (in_array($hp4['id'], [4, 6, 7, 8, 9]))
                    {
                        $f2 = true;
                        $home -= 30;
                        if ($this->debug) echo "四宫主失势落陷，且与火土天海冥成相，每多一个【-30】\n";
                    }
                }
            }
        }
//        3、    若1,2同时满足，此时家庭值>0,则令其【/3】
        if ($f1 === true && $f2 === true && $home > 0)
        {
            $home = $home / 3;
        }
//        最终：家庭值=（家庭值+300）/2
        $home = ($home + 300) / 2;

        return $home;
    }

    /**
     * 获取学业分数
     * @param int
     */
    protected function getTheStudy($debug = false)
    {
        $sun = $this->base_data['planets'][0];
        $moon = $this->base_data['planets'][1];
        $merc = $this->base_data['planets'][2];
        // 1、	基础值【哪个值大取哪个】=水星的力量+水星的活跃-水星的损伤+9宫的活跃+9宫的成就-9宫的挑战
        //   或=水星的力量+水星的活跃-水星的损伤+3宫的活跃+3宫的成就-3宫的挑战
//        $study1 = $this->planet_power[2]['stabilize'] + $this->planet_power[2]['active'] - $this->planet_power[2]['burn']
//            + ($this->house_score[9]['active'] + $this->house_score[9]['lucky'] - $this->house_score[9]['burn'] );
//        $study2 = $this->planet_power[2]['stabilize'] + $this->planet_power[2]['active'] - $this->planet_power[2]['burn']
//            + ($this->house_score[3]['active'] + $this->house_score[3]['lucky'] - $this->house_score[3]['burn'] );
        $study1 = $this->planet_power[2]['stabilize'] + $this->planet_power[2]['active'] + $this->house_score[9]['lucky'];
        $study2 = $this->planet_power[2]['stabilize'] + $this->planet_power[2]['active'] + $this->house_score[3]['lucky'];
        $study = ($study1 > $study2) ? $study1 / 3 : $study2 / 3;
        if ($debug === true) echo "基础值={$study}\n";
//        2、	若水星与木星有相位，【+150】；若此时，水星与天王也有相位【+80】；若此时，水星是命主或定位日月【+80】
        if (isset($merc['phase']['2-5']))
        {
            $study += 150;
            if ($debug === true) echo "若水星与木星有相位【+150】 = {$study}\n";
            if (isset($merc['phase']['2-7']))
            {
                $study += 80;
                if ($debug === true) echo "若水星与木星有相位,若此时，水星与天王也有相位【+80】 = {$study}\n";
            }
            if (
                $this->base_data['houses'][1]['protect_ancient_id'] == 2
                || $sun['ancient']['or_walls_planet_id'] == 2
                || $moon['ancient']['or_walls_planet_id'] == 2
            )
            {
                $study += 80;
                if ($debug === true) echo "若水星与木星有相位,若此时，水星是命主或定位日月【+80】 = {$study}\n";
            }
        }
//        3、	若水星落1/3/9/10，或落整宫制下的1/3/9/10【+80】
//        if(json_decode(session('setting.h_sys'),true)['natal'] == 'p')
//        {
        if (in_array($merc['in_house_id'], [1, 3, 9, 10]))
        {
            $study += 80;
            if ($debug === true) echo "若水星落1/3/9/10，【+80】 = {$study}\n";
        }
//        }
//        elseif(json_decode(session('setting.h_sys'),true)['natal'] == 'w')
//        {
//            if(in_array($merc['in_house_id'],[1,3,9,10]))
//            {
//                $study += 80;
//                if($debug === true) echo "若水星落整宫制下的1/3/9/10【+80】 = {$study}\n";
//            }
//        }
//        4、	若3/6/9宫或3/9/12宫成T三角，【-100】
//        p();
        if (!empty($this->base_data['structure']['t_square']))
        {
            foreach ($this->base_data['structure']['t_square'] as $t_square)
            {
                if (
                    (in_array($t_square[0]['in_house_id'], [3, 6, 9])
                        && in_array($t_square[2]['in_house_id'], [3, 6, 9])
                        && in_array($t_square[2]['in_house_id'], [3, 6, 9]))
                    || (in_array($t_square[0]['in_house_id'], [3, 9, 12])
                        && in_array($t_square[2]['in_house_id'], [3, 9, 12])
                        && in_array($t_square[2]['in_house_id'], [3, 9, 12]))
                )
                {
                    $study -= 100;
                    if ($debug === true) echo "若3/6/9宫或3/9/12宫成T三角，【-100】 = {$study}\n";
                }
            }
        }
//        5、	若3宫内水星刑月亮或3宫内月亮刑水星【-200】
        if (
            ($merc['in_house_id'] == 3 && isset($merc['phase']['2-1']) && $merc['phase']['2-1']['phase_e'] == 90)
            || ($moon['in_house_id'] == 3 && isset($moon['phase']['1-2']) && $moon['phase']['1-2']['phase_e'] == 90)
        )
        {
            $study -= 200;
            if ($debug === true) echo "若3宫内水星刑月亮或3宫内月亮刑水星【-200】 = {$study}\n";
        }
//        6、	若9宫内水星刑月亮或9宫内月亮刑水星【-150】
        if (
            ($merc['in_house_id'] == 9 && isset($merc['phase']['2-1']) && $merc['phase']['2-1']['phase_e'] == 90)
            || ($moon['in_house_id'] == 9 && isset($moon['phase']['1-2']) && $moon['phase']['1-2']['phase_e'] == 90)
        )
        {
            $study -= 150;
            if ($debug === true) echo "若3宫内水星刑月亮或3宫内月亮刑水星【-150】 = {$study}\n";
        }
//        7、	水星落双鱼与土星成相或水星落摩羯与海王成相或水星与土海同时成相【-120】，若此时水星在4宫【-30】8、12宫【-60】
        if (
            ($merc['in_sign_id'] == 12 && isset($merc['phase']['2-6']))
            || ($merc['in_sign_id'] == 10 && isset($merc['phase']['2-8']))
            || (isset($merc['phase']['2-6']) && isset($merc['phase']['2-8']))
        )
        {
            $study -= 120;
            if ($debug === true) echo "水星落双鱼与土星成相或水星落摩羯与海王成相或水星与土海同时成相【-120】 = {$study}\n";
            if ($merc['in_house_id'] == 4)
            {
                $study -= 30;
                if ($debug === true) echo "水星落双鱼与土星成相或水星落摩羯与海王成相或水星与土海同时成相,若此时水星在4宫【-30】 = {$study}\n";
            } elseif ($merc['in_house_id'] == 8 || $merc['in_house_id'] == 12)
            {
                $study -= 60;
                if ($debug === true) echo "水星落双鱼与土星成相或水星落摩羯与海王成相或水星与土海同时成相,若此时水星在8、12宫【-60】 = {$study}\n";
            }
        }

        return $study;
    }

    private function housePower($hid = null)
    {
        if ($hid !== null)
        {
            $house = $this->base_data['houses'][$hid];
            $status = $this->PlanetPower($house['protect_id']);
            if ($house['protect_id'] != $house['protect_ancient_id'])
            {
                $temp = $this->PlanetPower($house['protect_ancient_id']);
                if ($status['walls'] == 0 && $temp['walls'] == 1)
                {
                    $status['walls'] = 1;
                }
                if ($status['promote'] == 0 && $temp['promote'] == 1)
                {
                    $status['promote'] = 1;
                }
                $status['walls_accept'] = array_merge($status['walls_accept'], $temp['walls_accept']);
                $status['promote_accept'] = array_merge($status['promote_accept'], $temp['promote_accept']);
                $status['accept_each_other'] = array_merge($status['accept_each_other'], $temp['accept_each_other']);
                $status['accept_each_other_by_phase'] = array_merge($status['accept_each_other_by_phase'],
                    $temp['accept_each_other_by_phase']);
            }
        }
        return $status;
    }

    // 检查行星 入庙擢升  接纳互容情况
    private function PlanetPower($pid = null)
    {
        $ret = [
            'walls' => 0,
            'promote' => 0,
            'walls_accept' => [],
            'promote_accept' => [],
            'accept_each_other' => [],
            'accept_each_other_by_phase' => [],
        ];
        $p = $this->base_data['planets'][$pid];
        // 是否入庙
        if ($p['ancient']['walls'] == 1)
        {
            $ret['walls'] = 1;
        }
        // 是否擢升
        if ($p['ancient']['promote'] == 1)
        {
            $ret['promote'] = 1;
        }
        for ($i = 0; $i < 10; $i++)
        {
            $p1 = $this->base_data['planets'][$i];
            // 行星为当前行星时  是否接纳
            if (isset($p1['phase'][$i . '-' . $pid]))
            {
                if ($i != $pid && ($i == $p['ancient']['or_walls_planet_id']
                        || $i == config('astrolog.protect_id')[$p['in_sign_id'] - 1]))
                {
                    $ret['walls_accept'][$i] = 1;
                }
                if ($i != $pid && $i == $p['ancient']['or_promote_planet_id'])
                {
                    $ret['promote_accept'][$i] = 1;
                }
            }
            // 互容双方  当前行星
            if ($i != $pid &&
                (
                    $p['ancient']['or_walls_planet_id'] == $i
                    || config('astrolog.protect_id')[$p['in_sign_id'] - 1] == $i
                    || $p['ancient']['or_promote_planet_id'] == $i
                )
                && (
                    $p1['ancient']['or_walls_planet_id'] == $pid
                    || config('astrolog.protect_id')[$p1['in_sign_id'] - 1] == $pid
                    || $p1['ancient']['or_promote_planet_id'] == $pid
                )
            )
            {
                $ret['accept_each_other'][$i] = 1;
                if (isset($p1['phase'][$i . '-' . $pid]))
                {
                    $ret['accept_each_other_by_phase'][$i] = 1;// 有相位互容
                } else
                {
                    $ret['accept_each_other_by_phase'][$i] = 2;// 无相位互容
                }
            }
        }
        return $ret;
    }

    private function is_zhigao($id)
    {
        $mc_deg = $this->base_data['planets'][MC]['deg'];
        $min_diff = 360;
        $min_diff_id = null;
        foreach ($this->base_data['planets'] as $i => $planet)
        {
            $deg = $planet['deg'];
            $diff = abs($deg - $mc_deg);
            if ($diff > 180) $diff = 360 - $diff;
            if ($diff < $min_diff && $diff != 0 && $i < 10)
            {
                $min_diff_id = $i;
                $min_diff = $diff;
            }
        }
        if ($id == $min_diff_id) return true;
        return false;
    }

    /**
     * 检查两颗星是否互容接纳
     * @param null $pid1
     * @param null $pid2
     * @return bool
     */
    private function is_accept_each_other($pid1 = null, $pid2 = null)
    {
        if ($pid1 === null || $pid2 === null) return false;
        $p1 = $this->base_data['planets'][$pid1];
        $p2 = $this->base_data['planets'][$pid2];
        // 本源接纳 或 擢升接纳
        if (isset($p1['phase'][$pid1 . '-' . $pid2]))
        {
            if ($pid1 != $pid2 && ($pid1 == $p2['ancient']['or_walls_planet_id']
                    || $pid1 == config('astrolog.protect_id')[$p2['in_sign_id'] - 1]))
            {
                return true;
            }
            if ($pid1 != $pid2 && $pid1 == $p2['ancient']['or_promote_planet_id'])
            {
                return true;
            }
        }
        // 互容双方  当前行星
        if ($pid1 != $pid2 &&
            (
                $p2['ancient']['or_walls_planet_id'] == $pid1
                || config('astrolog.protect_id')[$p2['in_sign_id'] - 1] == $pid1
                || $p2['ancient']['or_promote_planet_id'] == $pid1
            )
            && (
                $p1['ancient']['or_walls_planet_id'] == $pid2
                || config('astrolog.protect_id')[$p1['in_sign_id'] - 1] == $pid2
                || $p1['ancient']['or_promote_planet_id'] == $pid2
            )
        )
        {
            return true;
        }
        return false;
    }

    protected function getLoveScore()
    {
        $venu = $this->base_data['planets'][3];
        $score = 500;
        #-----------------------------金星计算开始-----------------------------------#
        // 落6宫
        if ($venu['in_house_id'] == 6)
        {
            $score *= 0.9;
        } // 落8宫
        elseif ($venu['in_house_id'] == 8)
        {
            $score *= 0.8;
        } // 落12宫
        elseif ($venu['in_house_id'] == 12)
        {
            $score *= 0.65;
        }
        // 落处女、天蝎、白羊座
        if (in_array($venu['in_sign_id'], [1, 6, 8]))
        {
            $score *= 0.85;
        }
        // 与月星成相
        if (isset($venu['phase']['3-1']) && ($venu['phase']['3-1']['phase_e'] == 90 || $venu['phase']['3-1']['phase_e'] == 180))
        {
            $score *= 0.7;
        }
        // 与火星成相
        if (isset($venu['phase']['3-4']))
        {
            if ($venu['phase']['3-4']['phase_e'] == 90)
            {
                $score *= 0.7;
            } elseif ($venu['phase']['3-4']['phase_e'] == 180)
            {
                $score *= 0.8;
            }
        }
        // 与木星成相
        if (isset($venu['phase']['3-5']))
        {
            if ($venu['phase']['3-5']['phase_e'] == 90)
            {
                $score *= 0.85;
            } elseif ($venu['phase']['3-5']['phase_e'] == 180)
            {
                $score *= 0.75;
            }
        }
        // 与土星成相
        if (isset($venu['phase']['3-6']))
        {
            if ($venu['phase']['3-6']['phase_e'] == 90)
            {
                $score *= 0.7;
            } elseif ($venu['phase']['3-6']['phase_e'] == 180)
            {
                $score *= 0.65;
            } elseif ($venu['phase']['3-6']['phase_e'] == 0)
            {
                $score *= 0.7;
            }
        }
        // 与天、海、冥四分
        if ((isset($venu['phase']['3-7']) && $venu['phase']['3-7']['phase_e'] == 90)
            || (isset($venu['phase']['3-8']) && $venu['phase']['3-8']['phase_e'] == 90)
            || (isset($venu['phase']['3-9']) && $venu['phase']['3-9']['phase_e'] == 90))
        {
            $score *= 0.65;
        }
        // 与天、海、冥对分
        if ((isset($venu['phase']['3-7']) && $venu['phase']['3-7']['phase_e'] == 180)
            || (isset($venu['phase']['3-8']) && $venu['phase']['3-8']['phase_e'] == 180)
            || (isset($venu['phase']['3-9']) && $venu['phase']['3-9']['phase_e'] == 180))
        {
            $score *= 0.6;
        }
        // 与天、海、冥合相
        if ((isset($venu['phase']['3-7']) && $venu['phase']['3-7']['phase_e'] == 0)
            || (isset($venu['phase']['3-8']) && $venu['phase']['3-8']['phase_e'] == 0)
            || (isset($venu['phase']['3-9']) && $venu['phase']['3-9']['phase_e'] == 0))
        {
            $score *= 0.7;
        }
        // 计算金星成相数量 只计算日月水金火木土天海冥
        $venu_phase_total = 0;
        if (!empty($venu['phase']))
        {
            foreach ($venu['phase'] as $v)
            {
                if ($v['id'] < 10)
                {
                    $venu_phase_total++;
                }
            }
        }
        // 独与天海冥成相
        if ($venu_phase_total == 1)
        {
            if (isset($venu['phase']['3-7']) || isset($venu['phase']['3-8']) || isset($venu['phase']['3-9']))
            {
                $score *= 0.85;
            }
        }
//        p($this->base_data['structure']);
        // 落T三角顶点
        if (!empty($this->base_data['structure']['t_square']))
        {
            foreach ($this->base_data['structure']['t_square'] as $square)
            {
                if ($square[2]['id'] == 3) $score *= 0.8;
            }
        }

        #-----------------------------金星计算结束-----------------------------------#


        #-----------------------------7宫主计算开始-----------------------------------#
        $house7 = $this->base_data['houses'][7];
        $house7_protect = $this->base_data['planets'][$this->base_data['houses'][7]['protect_ancient_id']];
        // 落6宫
        if ($house7_protect['in_house_id'] == 6)
        {
            $score *= 0.75;
        } // 落8宫
        elseif ($house7_protect['in_house_id'] == 8)
        {
            $score *= 0.8;
        } // 落12宫
        elseif ($house7_protect['in_house_id'] == 12)
        {
            $score *= 0.65;
        }
        // 7宫主失势或落陷
        if ($house7_protect['ancient']['walls'] == 2 || $house7_protect['ancient']['promote'] == 2)
        {
            $score *= 0.9;
        }
        // 与太阳四分或对分
        if (isset($house7_protect['phase'][$house7_protect['id'] . '-0']))
        {
            if ($house7_protect['phase'][$house7_protect['id'] . '-0']['phase_e'] == 90
                || $house7_protect['phase'][$house7_protect['id'] . '-0']['phase_e'] == 180)
            {
                // 火土时
                if ($house7_protect['id'] == 4 || $house7_protect['id'] == 6)
                {
                    $score *= 0.8;
                } // 月木
                elseif ($house7_protect['id'] == 1 || $house7_protect['id'] == 5)
                {
                    $score *= 0.9;
                }
            }
        }
        // 与月亮四分或对分
        if (isset($house7_protect['phase'][$house7_protect['id'] . '-1']))
        {
            if ($house7_protect['phase'][$house7_protect['id'] . '-1']['phase_e'] == 90
                || $house7_protect['phase'][$house7_protect['id'] . '-1']['phase_e'] == 180)
            {
                // 火土
                if ($house7_protect['id'] == 4 || $house7_protect['id'] == 6)
                {
                    $score *= 0.7;
                } // 日金水木
                elseif ($house7_protect['id'] == 0 || $house7_protect['id'] == 2 || $house7_protect['id'] == 3 || $house7_protect['id'] == 5)
                {
                    $score *= 0.85;
                }
            }
        }
        // 与火星四分、合或对分
        if (isset($house7_protect['phase'][$house7_protect['id'] . '-4']))
        {
            // 四分、合
            if ($house7_protect['phase'][$house7_protect['id'] . '-4']['phase_e'] == 90
                || $house7_protect['phase'][$house7_protect['id'] . '-4']['phase_e'] == 0)
            {
                $score *= 0.8;
            } // 对分
            elseif ($house7_protect['phase'][$house7_protect['id'] . '-4']['phase_e'] == 180)
            {
                $score *= 0.7;
            }
        }
        // 与木星四分或对分
        if (isset($house7_protect['phase'][$house7_protect['id'] . '-5']))
        {
            // 四分
            if ($house7_protect['phase'][$house7_protect['id'] . '-5']['phase_e'] == 90)
            {
                $score *= 0.9;
            } // 对分
            elseif ($house7_protect['phase'][$house7_protect['id'] . '-5']['phase_e'] == 180)
            {
                $score *= 0.85;
            }
        }
        // 与土星四分、合或对分
        if (isset($house7_protect['phase'][$house7_protect['id'] . '-6']))
        {
            // 四分、合
            if ($house7_protect['phase'][$house7_protect['id'] . '-6']['phase_e'] == 90
                || $house7_protect['phase'][$house7_protect['id'] . '-6']['phase_e'] == 0)
            {
                $score *= 0.8;
            } // 对分
            elseif ($house7_protect['phase'][$house7_protect['id'] . '-6']['phase_e'] == 180)
            {
                $score *= 0.7;
            }
        }
        // 与天、海、冥四分
        if ((isset($house7_protect['phase'][$house7_protect['id'] . '-7']) && $house7_protect['phase'][$house7_protect['id'] . '-7']['phase_e'] == 90)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-8']) && $house7_protect['phase'][$house7_protect['id'] . '-8']['phase_e'] == 90)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-9']) && $house7_protect['phase'][$house7_protect['id'] . '-9']['phase_e'] == 90))
        {
            $score *= 0.75;
        }
        // 与天、海、冥对分
        if ((isset($house7_protect['phase'][$house7_protect['id'] . '-7']) && $house7_protect['phase'][$house7_protect['id'] . '-7']['phase_e'] == 180)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-8']) && $house7_protect['phase'][$house7_protect['id'] . '-8']['phase_e'] == 180)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-9']) && $house7_protect['phase'][$house7_protect['id'] . '-9']['phase_e'] == 180))
        {
            $score *= 0.65;
        }
        // 与天、海、冥合相
        if ((isset($house7_protect['phase'][$house7_protect['id'] . '-7']) && $house7_protect['phase'][$house7_protect['id'] . '-7']['phase_e'] == 0)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-8']) && $house7_protect['phase'][$house7_protect['id'] . '-8']['phase_e'] == 0)
            || (isset($house7_protect['phase'][$house7_protect['id'] . '-9']) && $house7_protect['phase'][$house7_protect['id'] . '-9']['phase_e'] == 0))
        {
            $score *= 0.75;
        }
        // 落T三角顶点
        if (!empty($this->base_data['structure']['t_square']))
        {
            foreach ($this->base_data['structure']['t_square'] as $square)
            {
                if ($square[2]['id'] == $house7_protect['id']) $score *= 0.8;
            }
        }

        #-----------------------------7宫主计算结束-----------------------------------#


        #-----------------------------7宫内计算开始-----------------------------------#
        $in_house7 = $this->base_data['houses'][7]['in_house_area_planet_info'];
        $in_house_total = 0;
        if (!empty($in_house7))
        {
            foreach ($in_house7 as $k => $pl)
            {
                $pid = $pl['id'];
                if ($pid < 10) $in_house_total++;
                if ($pid == 7)
                {
                    $score *= 0.75;
                } elseif ($pid == 8)
                {
                    $score *= 0.7;
                } elseif ($pid == 9)
                {
                    $score *= 0.75;
                } else
                {
                    $ancient = $this->base_data['planets'][$pid]['ancient'];
                    $change = 1;
                    if ($ancient['walls'] == 2 || $ancient['promote'] == 2)
                    {
                        if ($pid == 0) $change = 0.95;
                        elseif ($pid == 1) $change = 0.85;
                        elseif ($pid == 2) $change = 0.85;
                        elseif ($pid == 3) $change = 0.9;
                        elseif ($pid == 4) $change = 0.7;
                        elseif ($pid == 5) $change = 0.85;
                        elseif ($pid == 6) $change = 0.7;
                    } else
                    {
                        if ($pid == 0) $change = 1.2;
                        elseif ($pid == 1) $change = 0.95;
                        elseif ($pid == 2) $change = 0.9;
                        elseif ($pid == 3) $change = 1.2;
                        elseif ($pid == 4) $change = 0.8;
                        elseif ($pid == 5) $change = 0.9;
                        elseif ($pid == 6) $change = 0.75;
                    }
                    $score *= $change;
                }
                $in_house7_phase = $this->base_data['planets'][$pid]['phase'];
                if (!empty($in_house7_phase))
                {
                    if ((isset($in_house7_phase[$pid . '-7']) && $in_house7_phase[$pid . '-7']['phase_e'] == 180)
                        || (isset($in_house7_phase[$pid . '-8']) && $in_house7_phase[$pid . '-8']['phase_e'] == 180)
                        || (isset($in_house7_phase[$pid . '-9']) && $in_house7_phase[$pid . '-9']['phase_e'] == 180))
                    {
                        $score *= 0.6;
                    }
                    if ((isset($in_house7_phase[$pid . '-7']) && $in_house7_phase[$pid . '-7']['phase_e'] == 90)
                        || (isset($in_house7_phase[$pid . '-8']) && $in_house7_phase[$pid . '-8']['phase_e'] == 90)
                        || (isset($in_house7_phase[$pid . '-9']) && $in_house7_phase[$pid . '-9']['phase_e'] == 90))
                    {
                        $score *= 0.7;
                    }
                    if ((isset($in_house7_phase[$pid . '-4']) && $in_house7_phase[$pid . '-4']['phase_e'] == 180)
                        || (isset($in_house7_phase[$pid . '-6']) && $in_house7_phase[$pid . '-6']['phase_e'] == 180))
                    {
                        $score *= 0.7;
                    }
                    if ((isset($in_house7_phase[$pid . '-4']) && $in_house7_phase[$pid . '-4']['phase_e'] == 90)
                        || (isset($in_house7_phase[$pid . '-6']) && $in_house7_phase[$pid . '-6']['phase_e'] == 90))
                    {
                        $score *= 0.75;
                    }
                    if (isset($in_house7_phase[$pid . '-1']))
                    {
                        if ($in_house7_phase[$pid . '-1']['phase_e'] == 90 || $in_house7_phase[$pid . '-1']['phase_e'] == 180)
                        {
                            $score *= 0.75;
                        }
                    }
                    if ((isset($in_house7_phase[$pid . '-0']) &&
                            ($in_house7_phase[$pid . '-0']['phase_e'] == 90
                                || $in_house7_phase[$pid . '-0']['phase_e'] == 180))
                        || (isset($in_house7_phase[$pid . '-2']) &&
                            ($in_house7_phase[$pid . '-2']['phase_e'] == 90
                                || $in_house7_phase[$pid . '-2']['phase_e'] == 180))
                        || (isset($in_house7_phase[$pid . '-3']) &&
                            ($in_house7_phase[$pid . '-3']['phase_e'] == 90
                                || $in_house7_phase[$pid . '-3']['phase_e'] == 180))
                        || (isset($in_house7_phase[$pid . '-5']) &&
                            ($in_house7_phase[$pid . '-5']['phase_e'] == 90
                                || $in_house7_phase[$pid . '-5']['phase_e'] == 180)))
                    {
                        $score *= 0.8;
                    }
                }

            }
            // 落三颗星或以上
            if ($in_house_total >= 3)
            {
                $score *= 0.7;
            }
        }
        #-----------------------------7宫内计算结束-----------------------------------#


        #-----------------------------5宫主计算开始-----------------------------------#
        $house5 = $this->base_data['houses'][5];
        $house5_protect = $this->base_data['planets'][$house5['protect_ancient_id']];
        // 落6宫
        if ($house5_protect['in_house_id'] == 6)
        {
            $score *= 0.9;
        } // 落8宫
        elseif ($house5_protect['in_house_id'] == 8)
        {
            $score *= 0.8;
        } // 落12宫
        elseif ($house5_protect['in_house_id'] == 12)
        {
            $score *= 0.7;
        }
        // 5宫主失势或落陷
        if ($house5_protect['ancient']['walls'] == 2 || $house5_protect['ancient']['promote'] == 2)
        {
            $score *= 0.9;
        }
        // 与太阳四分或对分
        if (isset($house5_protect['phase'][$house5_protect['id'] . '-0']))
        {
            if ($house5_protect['phase'][$house5_protect['id'] . '-0']['phase_e'] == 90
                || $house5_protect['phase'][$house5_protect['id'] . '-0']['phase_e'] == 180)
            {
                // 火土时
                if ($house5_protect['id'] == 4 || $house5_protect['id'] == 6)
                {
                    $score *= 0.8;
                } // 月木
                elseif ($house5_protect['id'] == 1 || $house5_protect['id'] == 5)
                {
                    $score *= 0.9;
                }
            }
        }
        // 与月亮四分或对分
        if (isset($house5_protect['phase'][$house5_protect['id'] . '-1']))
        {
            if ($house5_protect['phase'][$house5_protect['id'] . '-1']['phase_e'] == 90
                || $house5_protect['phase'][$house5_protect['id'] . '-1']['phase_e'] == 180)
            {
                // 火土
                if ($house5_protect['id'] == 4 || $house5_protect['id'] == 6)
                {
                    $score *= 0.7;
                } // 日金水木
                elseif ($house5_protect['id'] == 0 || $house5_protect['id'] == 2 || $house5_protect['id'] == 3 || $house5_protect['id'] == 5)
                {
                    $score *= 0.85;
                }
            }
        }
        // 与火星四分、合或对分
        if (isset($house5_protect['phase'][$house5_protect['id'] . '-4']))
        {
            // 四分、合
            if ($house5_protect['phase'][$house5_protect['id'] . '-4']['phase_e'] == 90
                || $house5_protect['phase'][$house5_protect['id'] . '-4']['phase_e'] == 0)
            {
                $score *= 0.85;
            } // 对分
            elseif ($house5_protect['phase'][$house5_protect['id'] . '-4']['phase_e'] == 180)
            {
                $score *= 0.7;
            }
        }
        // 与木星四分或对分
        if (isset($house5_protect['phase'][$house5_protect['id'] . '-5']))
        {
            // 四分
            if ($house5_protect['phase'][$house5_protect['id'] . '-5']['phase_e'] == 90)
            {
                $score *= 0.9;
            } // 对分
            elseif ($house5_protect['phase'][$house5_protect['id'] . '-5']['phase_e'] == 180)
            {
                $score *= 0.85;
            }
        }
        // 与土星四分、合或对分
        if (isset($house5_protect['phase'][$house5_protect['id'] . '-6']))
        {
            // 四分、合
            if ($house5_protect['phase'][$house5_protect['id'] . '-6']['phase_e'] == 90
                || $house5_protect['phase'][$house5_protect['id'] . '-6']['phase_e'] == 0)
            {
                $score *= 0.8;
            } // 对分
            elseif ($house5_protect['phase'][$house5_protect['id'] . '-6']['phase_e'] == 180)
            {
                $score *= 0.7;
            }
        }
        // 与天、海、冥四分
        if ((isset($house5_protect['phase'][$house5_protect['id'] . '-7']) && $house5_protect['phase'][$house5_protect['id'] . '-7']['phase_e'] == 90)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-8']) && $house5_protect['phase'][$house5_protect['id'] . '-8']['phase_e'] == 90)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-9']) && $house5_protect['phase'][$house5_protect['id'] . '-9']['phase_e'] == 90))
        {
            $score *= 0.75;
        }
        // 与天、海、冥对分
        if ((isset($house5_protect['phase'][$house5_protect['id'] . '-7']) && $house5_protect['phase'][$house5_protect['id'] . '-7']['phase_e'] == 180)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-8']) && $house5_protect['phase'][$house5_protect['id'] . '-8']['phase_e'] == 180)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-9']) && $house5_protect['phase'][$house5_protect['id'] . '-9']['phase_e'] == 180))
        {
            $score *= 0.65;
        }
        // 与天、海、冥合相
        if ((isset($house5_protect['phase'][$house5_protect['id'] . '-7']) && $house5_protect['phase'][$house5_protect['id'] . '-7']['phase_e'] == 0)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-8']) && $house5_protect['phase'][$house5_protect['id'] . '-8']['phase_e'] == 0)
            || (isset($house5_protect['phase'][$house5_protect['id'] . '-9']) && $house5_protect['phase'][$house5_protect['id'] . '-9']['phase_e'] == 0))
        {
            $score *= 0.75;
        }
        // 落T三角顶点
        if (!empty($this->base_data['structure']['t_square']))
        {
            foreach ($this->base_data['structure']['t_square'] as $square)
            {
                if ($square[2]['id'] == $house5_protect['id']) $score *= 0.8;
            }
        }

        #-----------------------------5宫主计算结束-----------------------------------#


        #-----------------------------5宫内计算开始-----------------------------------#
        $in_house5 = $this->base_data['houses'][7]['in_house_area_planet_info'];
        $in_house5_total = 0;
        if (!empty($in_house5))
        {
            foreach ($in_house5 as $k => $pl)
            {
                $pid = $pl['id'];
                if ($pid < 10) $in_house5_total++;
                if ($pid == 7)
                {
                    $score *= 0.75;
                } elseif ($pid == 8)
                {
                    $score *= 0.7;
                } elseif ($pid == 9)
                {
                    $score *= 0.75;
                } else
                {
                    $ancient = $this->base_data['planets'][$pid]['ancient'];
                    $change = 1;
                    if ($ancient['walls'] == 2 || $ancient['promote'] == 2)
                    {
                        if ($pid == 0) $change = 0.95;
                        elseif ($pid == 1) $change = 0.85;
                        elseif ($pid == 2) $change = 0.85;
                        elseif ($pid == 3) $change = 0.9;
                        elseif ($pid == 4) $change = 0.7;
                        elseif ($pid == 5) $change = 0.85;
                        elseif ($pid == 6) $change = 0.7;
                    } else
                    {
                        if ($pid == 0) $change = 1.1;
                        elseif ($pid == 1) $change = 0.85;
                        elseif ($pid == 2) $change = 0.95;
                        elseif ($pid == 3) $change = 1.2;
                        elseif ($pid == 4) $change = 0.8;
                        elseif ($pid == 5) $change = 1.1;
                        elseif ($pid == 6) $change = 0.75;
                    }
                    $score *= $change;
                }
                $in_house5_phase = $this->base_data['planets'][$pid]['phase'];
                if (!empty($in_house5_phase))
                {
                    if ((isset($in_house5_phase[$pid . '-7']) && $in_house5_phase[$pid . '-7']['phase_e'] == 180)
                        || (isset($in_house5_phase[$pid . '-8']) && $in_house5_phase[$pid . '-8']['phase_e'] == 180)
                        || (isset($in_house5_phase[$pid . '-9']) && $in_house5_phase[$pid . '-9']['phase_e'] == 180))
                    {
                        $score *= 0.7;
                    }
                    if ((isset($in_house5_phase[$pid . '-7']) && $in_house5_phase[$pid . '-7']['phase_e'] == 90)
                        || (isset($in_house5_phase[$pid . '-8']) && $in_house5_phase[$pid . '-8']['phase_e'] == 90)
                        || (isset($in_house5_phase[$pid . '-9']) && $in_house5_phase[$pid . '-9']['phase_e'] == 90))
                    {
                        $score *= 0.7;
                    }
                    if ((isset($in_house5_phase[$pid . '-4']) && $in_house5_phase[$pid . '-4']['phase_e'] == 180)
                        || (isset($in_house5_phase[$pid . '-6']) && $in_house5_phase[$pid . '-6']['phase_e'] == 180))
                    {
                        $score *= 0.7;
                    }
                    if ((isset($in_house5_phase[$pid . '-4']) && $in_house5_phase[$pid . '-4']['phase_e'] == 90)
                        || (isset($in_house5_phase[$pid . '-6']) && $in_house5_phase[$pid . '-6']['phase_e'] == 90))
                    {
                        $score *= 0.75;
                    }
                    if (isset($in_house5_phase[$pid . '-1']))
                    {
                        if ($in_house5_phase[$pid . '-1']['phase_e'] == 90 || $in_house5_phase[$pid . '-1']['phase_e'] == 180)
                        {
                            $score *= 0.75;
                        }
                    }
                    if ((isset($in_house5_phase[$pid . '-0']) &&
                            ($in_house5_phase[$pid . '-0']['phase_e'] == 90
                                || $in_house5_phase[$pid . '-0']['phase_e'] == 180))
                        || (isset($in_house5_phase[$pid . '-2']) &&
                            ($in_house5_phase[$pid . '-2']['phase_e'] == 90
                                || $in_house5_phase[$pid . '-2']['phase_e'] == 180))
                        || (isset($in_house5_phase[$pid . '-3']) &&
                            ($in_house5_phase[$pid . '-3']['phase_e'] == 90
                                || $in_house5_phase[$pid . '-3']['phase_e'] == 180))
                        || (isset($in_house5_phase[$pid . '-5']) &&
                            ($in_house5_phase[$pid . '-5']['phase_e'] == 90
                                || $in_house5_phase[$pid . '-5']['phase_e'] == 180)))
                    {
                        $score *= 0.8;
                    }
                }

            }
            // 落三颗星或以上
            if ($in_house5_total >= 3)
            {
                $score *= 0.75;
            }
        }
        #-----------------------------5宫内计算结束-----------------------------------#


        #-----------------------------火星计算开始-----------------------------------#
        $fire = $this->base_data['planets'][4];
        // 落6宫
        if ($fire['in_house_id'] == 6)
        {
            $score *= 0.9;
        } // 落8宫
        elseif ($fire['in_house_id'] == 8)
        {
            $score *= 0.8;
        } // 落12宫
        elseif ($fire['in_house_id'] == 12)
        {
            $score *= 0.65;
        }
        // 落天秤、巨蟹、金牛
        if (in_array($fire['in_sign_id'], [2, 4, 7]))
        {
            $score *= 0.85;
        } elseif (in_array($fire['in_sign_id'], [11, 12]))
        {
            $score *= 0.9;
        }
        // 与土星成相
        if (isset($fire['phase']['4-6']))
        {
            if ($fire['phase']['4-6']['phase_e'] == 0 || $fire['phase']['4-6']['phase_e'] == 90 || $fire['phase']['4-6']['phase_e'] == 180)
            {
                $score *= 0.8;
            }
        }
        // 与天王星成相
        if (isset($fire['phase']['4-7']))
        {
            if ($fire['phase']['4-7']['phase_e'] == 0 || $fire['phase']['4-7']['phase_e'] == 90 || $fire['phase']['4-7']['phase_e'] == 180)
            {
                $score *= 0.75;
            }
        }
        // 与海王星成相
        if (isset($fire['phase']['4-8']))
        {
            if ($fire['phase']['4-8']['phase_e'] == 0 || $fire['phase']['4-8']['phase_e'] == 90 || $fire['phase']['4-8']['phase_e'] == 180)
            {
                $score *= 0.7;
            }
        }

        #-----------------------------火星计算结束-----------------------------------#
//        p($this->base_data['houses'][7]);
//        p($this->base_data['houses'][5]);
//        p($this->base_data['planets'][4]);
//        p($score);


//        p($this->planet_power);
        return $score;
    }
}
